Skip to content

Instantly share code, notes, and snippets.

@0mark
Last active December 21, 2015 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0mark/6282320 to your computer and use it in GitHub Desktop.
Save 0mark/6282320 to your computer and use it in GitHub Desktop.
Backup with rsync
#!/bin/sh
##### CONFIG
SRC=( "/home/mark" "/etc" )
BACKUPDIR=$1
#### DO NOT TOUCH
BACK=$(pwd)
if [ -d "${BACKUPDIR}" ]; then
cd ${BACKUPDIR}
for i in ${SRC[@]}; do
mkdir -p "./backup${i}"
PARM="--preserve-numerical-ids --exclude-device-files --exclude-fifos"
if [ -f $i/.exclude ]; then PARM="$PARM --exclude-globbing-filelist ${i}/.exclude"; fi
rdiff-backup $PARM -b "${i}" "./backup${i}" &> /var/log/rdbks.log
if [ $? -gt 0 ]; then
logger -t "rdbks" "Backup from $i to $BACKUPDIR failed!"
fi
done
cd $BACK
sleep 1
else
logger -t "rdbks" "Did not found $BACKUPDIR"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment