33 lines
1.3 KiB
Bash
33 lines
1.3 KiB
Bash
#!/usr/bin/env bashio
|
|
set +u
|
|
|
|
CONFIG_PATH=/data/options.json
|
|
SYSTEM_USER=/data/system_user.json
|
|
|
|
# grab user variables
|
|
BACKUP_ID=$(jq --raw-output ".backupID" $CONFIG_PATH)
|
|
PROTOCOL=$(jq --raw-output ".protocol" $CONFIG_PATH)
|
|
SSH_USERNAME=$(jq --raw-output ".ssh_username" $CONFIG_PATH)
|
|
SSH_PASSWORD=$(jq --raw-output ".ssh_password" $CONFIG_PATH)
|
|
BACKUP_SERVER=$(jq --raw-output ".server" $CONFIG_PATH)
|
|
BACKUP_SERVER_PATH=$(jq --raw-output ".path" $CONFIG_PATH)
|
|
FILTERS=$(jq --raw-output ".filters" $CONFIG_PATH)
|
|
CRONTAB_RUN=$(jq --raw-output ".crontab_run" $CONFIG_PATH)
|
|
DAYS_TO_KEEP=$(jq --raw-output ".days_to_keep" $CONFIG_PATH)
|
|
|
|
# edit the /.duplicacy/preferences file
|
|
sed --in-place 's/<BACKUP_ID>/'${BACKUP_ID}'/' /.duplicacy/preferences
|
|
sed --in-place 's/<PROTOCOL>/'${PROTOCOL}'/' /.duplicacy/preferences
|
|
sed --in-place 's/<SSH_USERNAME>/'${SSH_USERNAME}'/' /.duplicacy/preferences
|
|
sed --in-place 's/<SSH_PASSWORD>/'${SSH_PASSWORD}'/' /.duplicacy/preferences
|
|
sed --in-place 's/<BACKUP_SERVER>/'${BACKUP_SERVER}'/' /.duplicacy/preferences
|
|
sed --in-place 's~<BACKUP_SERVER_PATH>~'${BACKUP_SERVER_PATH}'~' /.duplicacy/preferences
|
|
|
|
# create the filters file
|
|
echo ${FILTERS} | jq -r '.[]' >> /.duplicacy/filters
|
|
|
|
# run the backup
|
|
/duplicacy -verbose -log backup -stats
|
|
|
|
# run the clean up
|
|
find /backup/* -type f -name '*.tar' -mtime +${DAYS_TO_KEEP} -exec rm {} \; |