Created
September 4, 2015 12:49
-
-
Save brodul/bb4abcd6978fe42438a7 to your computer and use it in GitHub Desktop.
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 | |
# this is runned as backup_user | |
# the user is in the backup group | |
# Add key | |
if [ -z "$SSH_AUTH_SOCK" ] ; then | |
eval `ssh-agent -s` | |
ssh-add | |
fi | |
# | |
HOST='10.66.0.XXX' | |
REPOSITORY=10.66.0.XXX:/srv/backup/dbrep.attic | |
ssh $HOST bash -c "' | |
# do db dumping | |
# Backup all of /home and /var/www except a few | |
# excluded directories | |
borg create --stats \ | |
$REPOSITORY::store_dbs-`date +%Y-%m-%d`--$RANDOM \ | |
/home/backup_user/all_databases.sql \ | |
/home/backup_user/*.txt | |
# Use the prune subcommand to maintain 7 daily, 4 weekly | |
# and 6 monthly archives. | |
borg prune -v $REPOSITORY --keep-daily=7 --keep-weekly=4 --keep-monthly=6 | |
'" | |
# could be killed nicer agent returns PID but https://www.youtube.com/watch?v=137zL_goITs | |
pkill ssh-agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment