Created
June 19, 2011 06:27
-
-
Save wozozo/1033828 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/bash | |
| # config | |
| SOURCES="/data /home/senko" | |
| BACKUP_DIR="/backup/mypc" | |
| # abort if any of the commands fail | |
| set -e | |
| todays=$(date +'%Y-%m-%d') # nicely sortable names for backups | |
| last=$(ls -r | head -1) | |
| to_delete=$(ls -r | tail -n +7) # will keep the last 6 backups | |
| cd $BACKUP_DIR | |
| ionice -c 3 nice -n +19 rsync -aq \ | |
| --link-dest=${BACKUP_DIR}/${last} $SOURCES $BACKUP_DIR/${todays} | |
| # now we're safe to remove the old one(s) | |
| [ -z "$to_delete" ] || rm -rf $to_delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment