Skip to content

Instantly share code, notes, and snippets.

@commuterjoy
Created December 26, 2011 15:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save commuterjoy/1521474 to your computer and use it in GitHub Desktop.
Incremental backup script
#!/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