initial commit.

This commit is contained in:
Rabjerg
2021-03-16 23:51:55 +01:00
commit 795bd9edbc
4 changed files with 190 additions and 0 deletions

43
make_backup.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/env bash
## Source backup.env file for settings and secrets.
## it is possible to pass a filename as .env file.
## Passing a file makes it possible to have several .env files for different backups and one "work script".
if [[ -z "$1" ]]; then
source backup.env
else
source $1
fi
## Setup that everything is written to log
exec > >(tee -i ${LOGFILE})
exec 2>&1
## Checks that a few important thins is set.
## In case a invalid path/file is passed.
if [[ -z $REPOSITORY ]]; then
echo "No \$REPOSITORY set, cannot make backup. \nDid you pass a valid .env file?"
exit 4
fi
if [[ -z $BACKUP_NAME ]]; then
echo "No \$BACKUP_NAME set, cannot make backup. \nDid you pass valid .env file?"
exit 5
fi
echo "######## Backup started at $(date) ########"
borg create -v --stats \
--exclude-from backup_exclude.txt \
$REPOSITORY::$BACKUP_NAME \
/home/adam/docker
echo "######### Backup Finished $(date) #########"