From c81fa5804011c1f98d57279eb6e5913719ec7415 Mon Sep 17 00:00:00 2001 From: deajan Date: Mon, 17 Jun 2013 13:27:37 +0200 Subject: [PATCH] Added some rsync parameters --- CHANGELOG.md | 2 ++ TODO.md | 1 - host_backup.conf | 11 ++++++++--- obackup.sh | 26 +++++++++++++++++++++++--- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e167b58..cd6b683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Latest changelog +- Added some Rsync argument parameters (preserve ACL, Xattr, and stream compression) +- Internal hook execution logic revised - Updated WaitForTaskCompletition function to handle skipping alerts - Updated command line argument --silent processing - Added remote before and after command execution hook diff --git a/TODO.md b/TODO.md index be83369..ec89649 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ Upcomming features: - Write proper documentation -- Add option to enable ACL backup (with rsync, and tar rotated copies) Bugs not yet addressed that will be done a bit later: diff --git a/host_backup.conf b/host_backup.conf index 30ac6e8..c46348f 100755 --- a/host_backup.conf +++ b/host_backup.conf @@ -57,14 +57,20 @@ COMPRESSION_REMOTE=yes ## Path separator. You can set whatever seperator you want in your directories list below. You may change this in case you have some esoteric filenames (try to use unconventional separators like | ). PATH_SEPARATOR_CHAR=";" -## File backup lists. Simple double quoted directory list separated by the $PATH_SEPARATOR_CHAR. Every directory will be processed as task (see documentation for explanation about tasks) +## File backup lists. Double quoted directory list separated by the $PATH_SEPARATOR_CHAR. Every directory will be processed as task (see documentation for explanation about tasks) DIRECTORIES_SIMPLE_LIST="/var/named" ## Recurse directory list separated by the $PATH_SEPARATOR_CHAR. Will create a backup task per subdirectory (one level only), eg RECURSE_LIST="/home /var" will create tasks "/home/dir1", "/home/dir2", ... "/home/dirN", "/var/log", "/var/lib"... "/var/whatever" DIRECTORIES_RECURSE_LIST="/home" ## You can optionally exclude directories from RECURSE_LIST tasks, eg on the above example you could exclude /home/dir2 by adding it to RECURSE_EXCLUDE_LIST DIRECTORIES_RECURSE_EXCLUDE_LIST="/home/backupuser;/home/lost+found" -# Be aware that every recurse list will have it's own root (exclude pattern is relative from /home/web for /home/web/{recursedir}) +## Be aware that every recurse list will have it's own root (exclude pattern is relative from /home/web for /home/web/{recursedir}) RSYNC_EXCLUDE_PATTERN="*/tmp;*/ftp/www/cache/cachefs;*/sessions" +## Preserve ACLS. Make sure target FS can hold ACLs or you'll get loads of errors. +PRESERVE_ACL=yes +## Preserve Xattr +PRESERVE_XATTR=yes +## Let RSYNC compress file transfers. Do not use if you already enabled SSH compression. +RSYNC_COMPRESS=yes ## Max execution time per file backup task. Soft is warning only. Hard is warning, stopping backup and processing next one one file list. Tilme is specified in seconds SOFT_MAX_EXEC_TIME_FILE_TASK=3600 HARD_MAX_EXEC_TIME_FILE_TASK=7200 @@ -91,4 +97,3 @@ REMOTE_RUN_AFTER_CMD="" MAX_EXEC_TIME_PER_CMD_BEFORE=0 MAX_EXEC_TIME_PER_CMD_AFTER=0 - diff --git a/obackup.sh b/obackup.sh index 140b049..8bf63dc 100755 --- a/obackup.sh +++ b/obackup.sh @@ -2,7 +2,7 @@ ###### Remote (or local) backup script for files & databases ###### (L) 2013 by Ozy de Jong (www.badministrateur.com) -OBACKUP_VERSION=1.83 #### Build 1606201303 +OBACKUP_VERSION=1.83 #### Build 1706201301 DEBUG=no SCRIPT_PID=$$ @@ -705,6 +705,25 @@ function RsyncExcludePattern IFS=$OLD_IFS } +function RsyncArgs +{ + RSYNC_ARGS=-rlptgoDE + if [ "$PRESERVE_ACLS" == "yes" ] + then + RSYNC_ARGS=$RSYNC_ARGS"A" + fi + + if [ "$PRESERVE_XATTR" == "yes" ] + then + RSYNC_ARGS=$RSYNC_ARGS"X" + fi + + if [ "$RSYNC_COMPRESS" == "yes" ] + then + RSYNC_ARGS=$RSYNC_ARGS"z" + fi +} + function Rsync { i="$(StripQuotes $1)" @@ -734,9 +753,9 @@ function Rsync LogError "Connectivity test failed. Stopping current task." exit 1 fi - rsync_cmd="$(which rsync) -rlptgoDE --delete $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$(which ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -p $REMOTE_PORT\" \"$REMOTE_USER@$REMOTE_HOST:$1\" \"$local_file_storage_path\" > /dev/shm/obackup_rsync_output_$SCRIPT_PID 2>&1" + rsync_cmd="$(which rsync) $RSYNC_ARGS --delete $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" -e \"$(which ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -p $REMOTE_PORT\" \"$REMOTE_USER@$REMOTE_HOST:$1\" \"$local_file_storage_path\" > /dev/shm/obackup_rsync_output_$SCRIPT_PID 2>&1" else - rsync_cmd="$(which rsync) -rlptgoDE --delete $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$1\" \"$local_file_storage_path\" > /dev/shm/obackup_rsync_output_$SCRIPT_PID 2>&1" + rsync_cmd="$(which rsync) $RSYNC_ARGS --delete $RSYNC_EXCLUDE --rsync-path=\"$RSYNC_PATH\" \"$1\" \"$local_file_storage_path\" > /dev/shm/obackup_rsync_output_$SCRIPT_PID 2>&1" fi #### Eval is used so the full command is processed without bash adding single quotes round variables if [ "$DEBUG" == "yes" ] @@ -914,6 +933,7 @@ function Main RotateBackups $LOCAL_FILE_STORAGE fi RsyncExcludePattern + RsyncArgs FilesBackup fi # Be a happy sysadmin (and drink a coffee ? Nahh... it's past midnight.)