Created
April 19, 2015 14:57
-
-
Save rzbrk/e890cbb21bb499b7e451 to your computer and use it in GitHub Desktop.
Backup Script based on rdiff-backup
This file contains 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/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