-
-
Save devsekhar/1dde9481b900021e72ae125997efd83a to your computer and use it in GitHub Desktop.
duplicity.backup Bash Script with Rollbar Notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export FTP_PASSWORD="123456" | |
FTP_USER="user" | |
FTP_HOST="user.your-backup.de" | |
BACKUP_TARGET="ftp://${FTP_USER}@${FTP_HOST}/$(hostname)" | |
DUPLICITY_LOGFILE="/var/log/duplicity.log" | |
DUPLICITY_TEMPDIR="/tmp/duplicity" | |
# Rollbar access token | |
ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxx | |
test -x $(which duplicity) || exit 0 | |
mkdir -p "${DUPLICITY_TEMPDIR}" | |
cd ${DUPLICITY_TEMPDIR} | |
curl -H "Content-Type: application/json" -d '{"access_token":"'"${ACCESS_TOKEN}"'","data":{"environment":"production","level":"info","title":"Backup started '"$(hostname -f)"'","body":{"message":{"body":"Backup started '"$(hostname -f)"'"}}}}' https://api.rollbar.com/api/1/item/ | |
OUT1="$($(which duplicity) incr --allow-source-mismatch --no-encryption -v3 --ftp-passive --tempdir="${DUPLICITY_TEMPDIR}" --full-if-older-than "1W" --volsize=250 --log-file="${DUPLICITY_LOGFILE}" --include /var/www/files --include /etc --include /home --include /root --exclude '/**' / "${BACKUP_TARGET}" 2>&1)" | |
OUT2="$($(which duplicity) remove-all-but-n-full 8 --allow-source-mismatch -v3 --ftp-passive --force "${BACKUP_TARGET}" 2>&1)" | |
echo -e $OUT1; | |
echo -e $OUT2; | |
payload='{"access_token":"'"${ACCESS_TOKEN}"'","data":{"environment":"production","level":"info","title":"Backup finished '"$(hostname -f)"'","body":{"message":{"body":"'"${OUT1}"'\n\n'"${OUT2}"'"}}}}'; | |
curl -H "Content-Type: application/json" -d "${payload}" https://api.rollbar.com/api/1/item/ | |
unset FTP_PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment