Skip to content

Instantly share code, notes, and snippets.

@rzbrk
Created April 19, 2015 14:57
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 rzbrk/e890cbb21bb499b7e451 to your computer and use it in GitHub Desktop.
Save rzbrk/e890cbb21bb499b7e451 to your computer and use it in GitHub Desktop.
Backup Script based on rdiff-backup
#!/bin/bash
# Specify the directory which has to be backed up
src="/home/user/"
# Specify the directory to place the backup
dst="rdiff_user@servername::remote_path"
# Specify a file which defines the direcories or files to be EXCLUDED
# from backup
excl=/root/rdiff-excl.txt
##########################################################################
# Define some variables
srv=$(echo $dst | grep -oP "\@\K([^:]+)")
rdiff_bin="/usr/bin/rdiff-backup"
rdiff_opts="--exclude-special-files --exclude-other-filesystems"
# If server is present, perform backup
ping -c 1 $srv > /dev/null 2>&1
if [ $?==0 ];
then
echo "Host $srv available. Perform backup ..."
$rdiff_bin $rdiff_opts --exclude-globbing-filelist $excl $src $dst
else
echo "Host $srv not available. Bye!"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment