From dc784a2671c0c7899cec45a0f8e10302bd341f19 Mon Sep 17 00:00:00 2001 From: deajan Date: Thu, 27 Nov 2014 15:35:56 +0100 Subject: [PATCH] Backup files and directories reffered by symlinks --- CHANGELOG.md | 5 +++-- host_backup.conf | 13 ++++++++++++- obackup.sh | 18 +++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8c7634..0295bb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ SHORT FUTURE IMPROVEMENTS - Rewrite rsync exclude patterns using \"pattern\" instead of escaped chars - Clean most of recursive task creation code -- Add symlink support (-L) and edit find -xtype d instead of -type d (xtype won't work with FreeBSD) KNOWN ISSUES ------------ @@ -16,12 +15,14 @@ UNDER WORK ---------- - Commands like cp should have their stderr redirected to log file -- Mysqldump must be checked for not telling success if a table is damaged +- Mysqldump must be checked for not telling success if a table is damaged (also check for event table error) CHANGELOG --------- +- WARNING: Default behavior is now to copy the referrent files and directories from symlinks (this can reach files outside the backup root) +- Recursive directory search now includes symlinks (find -L option. -type d cannot be replaced by -xtype d because of portability issues with BSD) - Dry mode does not create target directories anymore - Dry mode also tries mysqldumps now (check for error messages being logged) - Added experimental partial download support diff --git a/host_backup.conf b/host_backup.conf index d2055a6..0f3c17a 100755 --- a/host_backup.conf +++ b/host_backup.conf @@ -2,7 +2,7 @@ ###### Remote (or local) backup script for files & databases ###### (L) 2013 by Ozy de Jong (www.netpower.fr) -###### Config file rev 2411201401 +###### Config file rev 2711201401 ## ---------- GENERAL BACKUP OPTIONS @@ -121,6 +121,14 @@ PRESERVE_ACL=no ## Preserve Xattr. MAke sure source and target FS can hold same Xattr or you'll get loads of errors. PRESERVE_XATTR=no +## Transforms symlinks into referent files/dirs +COPY_SYMLINKS=yes +## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root. +KEEP_DIRLINKS=yes +## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them. +PRESERVE_HARDLINKS=no + + ## Let RSYNC compress file transfers. Do not use this on local-local backup schemes. Also, this is not usefull if SSH compression is enabled. RSYNC_COMPRESS=no @@ -128,6 +136,9 @@ RSYNC_COMPRESS=no SOFT_MAX_EXEC_TIME_FILE_TASK=3600 HARD_MAX_EXEC_TIME_FILE_TASK=7200 +## Keep partial uploads that can be resumed on next run, experimantal feature +PARTIAL=no + ## ---------- ALERT OPTIONS ## Alert email adresses separated by a space character diff --git a/obackup.sh b/obackup.sh index f7e4191..2865f62 100755 --- a/obackup.sh +++ b/obackup.sh @@ -5,7 +5,7 @@ AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.84preRC4 -PROGRAM_BUILD=2711201402 +PROGRAM_BUILD=2711201404 ## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode if ! type -p "$BASH" > /dev/null @@ -860,10 +860,10 @@ function ListDirectories LogError "Connectivity test failed. Stopping current task." Dummy & else - eval "$SSH_CMD \"$COMMAND_SUDO $FIND_CMD $dir/ -mindepth 1 -maxdepth 1 -type d\" > $RUN_DIR/obackup_dirs_recurse_list_$SCRIPT_PID &" + eval "$SSH_CMD \"$COMMAND_SUDO $FIND_CMD -L $dir/ -mindepth 1 -maxdepth 1 -type d\" > $RUN_DIR/obackup_dirs_recurse_list_$SCRIPT_PID &" fi else - eval "$COMMAND_SUDO $FIND_CMD $dir/ -mindepth 1 -maxdepth 1 -type d > $RUN_DIR/obackup_dirs_recurse_list_$SCRIPT_PID &" + eval "$COMMAND_SUDO $FIND_CMD -L $dir/ -mindepth 1 -maxdepth 1 -type d > $RUN_DIR/obackup_dirs_recurse_list_$SCRIPT_PID &" fi child_pid=$! WaitForTaskCompletion $child_pid $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK @@ -1261,6 +1261,18 @@ function Init then RSYNC_ARGS=$RSYNC_ARGS"z" fi + if [ "$COPY_SYMLINKS" != "no" ] + then + RSYNC_ARGS=$RSYNC_ARGS" -L" + fi + if [ "$KEEP_DIRLINKS" != "no" ] + then + RSYNC_ARGS=$RSYNC_ARGS" -K" + fi + if [ "$PRESERVE_HARDLINKS" == "yes" ] + then + RSYNC_ARGS=$RSYNC_ARGS" -H" + fi if [ $verbose -eq 1 ] then RSYNC_ARGS=$RSYNC_ARGS"i"