Skip to content

Instantly share code, notes, and snippets.

@carlosjac
Created April 6, 2011 12:42
Show Gist options
  • Select an option

  • Save carlosjac/905578 to your computer and use it in GitHub Desktop.

Select an option

Save carlosjac/905578 to your computer and use it in GitHub Desktop.
backup transfer script
#!/bin/sh
# source directory containing files to transfer
LBDIR=/backups/daily.0
# destination directory
DBDIR=user@server.com:remotedirectory
#########################################################################
BACKUPDIR=`date +%A`
OPTS="--force --ignore-errors --delete -avz -e ssh"
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
# empty destination directory
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir
rsync -e ssh --delete -a $HOME/emptydir/ $DBDIR/$BACKUPDIR/
rmdir $HOME/emptydir
# now the actual transfer
rsync $OPTS $LBDIR $DBDIR/$BACKUPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment