Created
December 26, 2011 15:52
-
-
Save commuterjoy/1521474 to your computer and use it in GitHub Desktop.
Incremental backup script
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 | |
# incremental backup script, tar and rsync's any file modified since the script last ran | |
CONTROL=/Users/user/Backups/backup.control | |
DEST=/Users/user/Backups/`date +%Y%m%d`-24hrs | |
DESTTAR=/Users/user/Backups/`date +%Y%m%d` | |
# create a tarball of modified files | |
mkdir -p $DEST | |
mkdir -p $DESTTAR | |
find /Users/user/Documents/Work/ -type f -newer ${CONTROL} -print | cpio -pvdmu $DEST | |
tar -cvf $DESTTAR/`date +%Y%m%d`.tar $DEST | |
# transfer | |
/usr/bin/rsync -av $DESTTAR user@host:path | |
# tidy & touch the control file to say we've ran | |
rm -Rf $DEST | |
touch ${CONTROL} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment