Last active
January 25, 2018 15:48
-
-
Save yottatsa/085b2623b774843e7ea242d3236d058d to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh -e | |
| # Author: yottatsa | |
| su - yottatsa -c 'make backup' 2>&1 | /usr/bin/logger -t backup | |
| if \ | |
| [ $(date -d "today" "+%m") -ne $(date -d "tomorrow" "+%m") ] || \ | |
| [ "$(date '+%a')" = "Tue" -a $(date +%d) -lt 29 -a $(date +%d) -gt 2 ] | |
| then | |
| ( | |
| cd "/media/portable/backup" | |
| mask="$(readlink latest | sed 's,-..$,,')" | |
| file="$(echo $mask | sed 's,-,_,').tar.gz" | |
| tar czf "${file}" -C ./ "$mask"* latest | |
| find -maxdepth 1 -name '*.gpg' -delete | |
| gpg --yes --encrypt -r {{ backup_recipient }} "${file}" | |
| find -maxdepth 1 -name '*.tar.gz' -delete | |
| s3cmd put "${file}.gpg" s3://{{ backup_bucket }}/ | |
| ) 2>&1 | /usr/bin/logger -t backup | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment