Lots of fixes and improvements for beta 3
This commit is contained in:
parent
1996e5790a
commit
fe3ab75278
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -1,16 +1,28 @@
|
||||||
|
FUTURE IMPROVEMENTS
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Merge master and slave functions
|
||||||
|
- Merge tree current and after functions
|
||||||
|
- Tree functions execute piped commands (grep, awk) on master when launched on remote slave, can cause more bandwith usage
|
||||||
|
|
||||||
KNOWN ISSUES
|
KNOWN ISSUES
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- Cannot write pidlock on remote slave with SUDO_EXEC=yes but insufficient rights (sudo does not work for command echo)
|
(v?)- Cannot write pidlock on remote slave with SUDO_EXEC=yes but insufficient rights (sudo does not work for command echo)
|
||||||
- If master and remote slave aren't the same distros and rsync binary isn't in the same path, execution may fail (RSYNC_PATH should be configurable)
|
- If master and remote slave aren't the same distros and rsync binary isn't in the same path, execution may fail (RSYNC_PATH should be configurable)
|
||||||
- Possible non deleted file with space in name on master replica from slave remote replica
|
- Possible non deleted file with space in name on master replica from slave remote replica
|
||||||
- Tree functions do not use RSYNC_ARGS
|
- can load configuration files that don't have .conf extension...
|
||||||
- Tree functions execute piped commands (grep, awk) on master when launched on remote slave
|
|
||||||
- comm v5.97 (as on CentOS 5) does not know option --nocheckorder
|
|
||||||
|
|
||||||
RECENT CHANGES
|
RECENT CHANGES
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
- 03 Aug. 2013: beta 3 milestone
|
||||||
|
- Softdelete functions do now honor --dry switch
|
||||||
|
- Simplified sync delete functions
|
||||||
|
- Enhanced compatibility with different charsets in filenames
|
||||||
|
- Added CentOS 5 compatibility (comm v5.97 without --nocheck-order function replaced by sort)
|
||||||
|
- Tree functions now honor supplementary rsync arguments
|
||||||
|
- Tree functions now honor exclusion lists
|
||||||
- 01 Aug. 2013: beta 2 milestone
|
- 01 Aug. 2013: beta 2 milestone
|
||||||
- Fixed an issue with spaces in directory trees
|
- Fixed an issue with spaces in directory trees
|
||||||
- Fixed an issue with recursive directory trees
|
- Fixed an issue with recursive directory trees
|
||||||
|
|
78
osync.sh
78
osync.sh
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
###### Osync - Rsync based two way sync engine with fault tolerance
|
###### Osync - Rsync based two way sync engine with fault tolerance
|
||||||
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
|
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
|
||||||
OSYNC_VERSION=0.97
|
OSYNC_VERSION=0.98
|
||||||
OSYNC_BUILD=3107201305
|
OSYNC_BUILD=0308201303
|
||||||
|
|
||||||
DEBUG=no
|
DEBUG=no
|
||||||
SCRIPT_PID=$$
|
SCRIPT_PID=$$
|
||||||
|
@ -20,6 +20,9 @@ OSYNC_DIR=".osync_workdir"
|
||||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log won't be unnecessary big.
|
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log won't be unnecessary big.
|
||||||
KEEP_LOGGING=1801
|
KEEP_LOGGING=1801
|
||||||
|
|
||||||
|
## Correct output of sort command (language agnostic sorting)
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
function Log
|
function Log
|
||||||
{
|
{
|
||||||
echo -e "TIME: $SECONDS - $1" >> "$LOG_FILE"
|
echo -e "TIME: $SECONDS - $1" >> "$LOG_FILE"
|
||||||
|
@ -694,7 +697,8 @@ function UnlockDirectories
|
||||||
function master_tree_current
|
function master_tree_current
|
||||||
{
|
{
|
||||||
Log "Creating master replica file list."
|
Log "Creating master replica file list."
|
||||||
$(which $RSYNC_EXECUTABLE) --rsync-path="$RSYNC_PATH" -rlptgoDE --exclude "$OSYNC_DIR" --list-only "$MASTER_SYNC_DIR/" | grep "^-\|^d" | awk '{$1=$2=$3=$4="" ;print}' | awk '{$1=$1 ;print}' | (grep -v "^\.$" || :) > /dev/shm/osync_master-tree-current_$SCRIPT_PID &
|
## Tree listing function: list | remove everything not file or directory | remove first 4 columns | remove empty leading spaces | remove "." dir (or return true if not exist)
|
||||||
|
$(which $RSYNC_EXECUTABLE) --rsync-path="$RSYNC_PATH" -rlptgoDE8 $RSYNC_ARGS --exclude "$OSYNC_DIR" $RSYNC_EXCLUDE --list-only "$MASTER_SYNC_DIR/" | grep "^-\|^d" | awk '{$1=$2=$3=$4="" ;print}' | awk '{$1=$1 ;print}' | (grep -v "^\.$" || :) | sort > /dev/shm/osync_master-tree-current_$SCRIPT_PID &
|
||||||
child_pid=$!
|
child_pid=$!
|
||||||
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME
|
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME $HARD_MAX_EXEC_TIME
|
||||||
if [ $? == 0 ] && [ -f /dev/shm/osync_master-tree-current_$SCRIPT_PID ]
|
if [ $? == 0 ] && [ -f /dev/shm/osync_master-tree-current_$SCRIPT_PID ]
|
||||||
|
@ -713,9 +717,9 @@ function slave_tree_current
|
||||||
Log "Creating slave replica file list."
|
Log "Creating slave replica file list."
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE --exclude \"$OSYNC_DIR\" -e \"$RSYNC_SSH_CMD\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) > /dev/shm/osync_slave-tree-current_$SCRIPT_PID &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE -e \"$RSYNC_SSH_CMD\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > /dev/shm/osync_slave-tree-current_$SCRIPT_PID &"
|
||||||
else
|
else
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE --exclude \"$OSYNC_DIR\" --list-only \"$SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) > /dev/shm/osync_slave-tree-current_$SCRIPT_PID &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS --exclude \"$OSYNC_DIR\" $RSNYC_EXCLUDE --list-only \"$SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > /dev/shm/osync_slave-tree-current_$SCRIPT_PID &"
|
||||||
fi
|
fi
|
||||||
if [ "$DEBUG" == "yes" ]
|
if [ "$DEBUG" == "yes" ]
|
||||||
then
|
then
|
||||||
|
@ -741,7 +745,7 @@ function master_delete_list
|
||||||
Log "Creating master replica deleted file list."
|
Log "Creating master replica deleted file list."
|
||||||
if [ -f "$MASTER_STATE_DIR/master-tree-after" ]
|
if [ -f "$MASTER_STATE_DIR/master-tree-after" ]
|
||||||
then
|
then
|
||||||
comm --nocheck-order -23 "$MASTER_STATE_DIR/master-tree-after" "$MASTER_STATE_DIR/master-tree-current" > "$MASTER_STATE_DIR/master-deleted-list"
|
comm -23 "$MASTER_STATE_DIR/master-tree-after" "$MASTER_STATE_DIR/master-tree-current" > "$MASTER_STATE_DIR/master-deleted-list"
|
||||||
echo "master-replica-deleted-list.success" > "$MASTER_STATE_DIR/last-action"
|
echo "master-replica-deleted-list.success" > "$MASTER_STATE_DIR/last-action"
|
||||||
else
|
else
|
||||||
touch "$MASTER_STATE_DIR/master-deleted-list"
|
touch "$MASTER_STATE_DIR/master-deleted-list"
|
||||||
|
@ -754,7 +758,7 @@ function slave_delete_list
|
||||||
Log "Creating slave replica deleted file list."
|
Log "Creating slave replica deleted file list."
|
||||||
if [ -f "$MASTER_STATE_DIR/slave-tree-after" ]
|
if [ -f "$MASTER_STATE_DIR/slave-tree-after" ]
|
||||||
then
|
then
|
||||||
comm --nocheck-order -23 "$MASTER_STATE_DIR/slave-tree-after" "$MASTER_STATE_DIR/slave-tree-current" > "$MASTER_STATE_DIR/slave-deleted-list"
|
comm -23 "$MASTER_STATE_DIR/slave-tree-after" "$MASTER_STATE_DIR/slave-tree-current" > "$MASTER_STATE_DIR/slave-deleted-list"
|
||||||
echo "slave-replica-deleted-list.success" > "$MASTER_STATE_DIR/last-action"
|
echo "slave-replica-deleted-list.success" > "$MASTER_STATE_DIR/last-action"
|
||||||
else
|
else
|
||||||
touch "$MASTER_STATE_DIR/slave-deleted-list"
|
touch "$MASTER_STATE_DIR/slave-deleted-list"
|
||||||
|
@ -769,7 +773,7 @@ function sync_update_slave
|
||||||
then
|
then
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui -e \"$RSYNC_SSH_CMD\" $SLAVE_BACKUP --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" \"$MASTER_SYNC_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" > /dev/shm/osync_update_slave_replica_$SCRIPT_PID 2>&1 &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui -e \"$RSYNC_SSH_CMD\" $SLAVE_BACKUP --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" \"$MASTER_SYNC_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" > /dev/shm/osync_update_slave_replica_$SCRIPT_PID 2>&1 &"
|
||||||
else
|
else
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDEui $SLAVE_BACKUP --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" \"$MASTER_SYNC_DIR/\" \"$SLAVE_SYNC_DIR/\" > /dev/shm/osync_update_slave_replica_$SCRIPT_PID 2>&1 &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $SLAVE_BACKUP --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" \"$MASTER_SYNC_DIR/\" \"$SLAVE_SYNC_DIR/\" > /dev/shm/osync_update_slave_replica_$SCRIPT_PID 2>&1 &"
|
||||||
fi
|
fi
|
||||||
if [ "$DEBUG" == "yes" ]
|
if [ "$DEBUG" == "yes" ]
|
||||||
then
|
then
|
||||||
|
@ -834,9 +838,10 @@ function delete_on_slave
|
||||||
Log "Propagating deletitions to slave replica."
|
Log "Propagating deletitions to slave replica."
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui -e \"$RSYNC_SSH_CMD\" $SLAVE_DELETE --delete --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" --include-from \"$MASTER_STATE_DIR/master-deleted-list\" \"$MASTER_SYNC_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" > /dev/shm/osync_deletition_on_slave_$SCRIPT_PID 2>&1 &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui -e \"$RSYNC_SSH_CMD\" $SLAVE_DELETE --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/master-deleted-list\" --exclude=\"*\" \"$MASTER_SYNC_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" > /dev/shm/osync_deletition_on_slave_$SCRIPT_PID 2>&1 &"
|
||||||
else
|
else
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $SLAVE_DELETE --delete --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" --include-from \"$MASTER_STATE_DIR/master-deleted-list\" \"$MASTER_SYNC_DIR/\" \"$SLAVE_SYNC_DIR/\" > /dev/shm/osync_deletition_on_slave_$SCRIPT_PID 2>&1 &"
|
#rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $SLAVE_DELETE --delete --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/slave-deleted-list\" --include-from \"$MASTER_STATE_DIR/master-deleted-list\" \"$MASTER_SYNC_DIR/\" \"$SLAVE_SYNC_DIR/\" > /dev/shm/osync_deletition_on_slave_$SCRIPT_PID 2>&1 &"
|
||||||
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $SLAVE_DELETE --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/master-deleted-list\" --exclude=\"*\" \"$MASTER_SYNC_DIR/\" \"$SLAVE_SYNC_DIR/\" > /dev/shm/osync_deletition_on_slave_$SCRIPT_PID 2>&1 &"
|
||||||
fi
|
fi
|
||||||
if [ "$DEBUG" == "yes" ]
|
if [ "$DEBUG" == "yes" ]
|
||||||
then
|
then
|
||||||
|
@ -866,9 +871,10 @@ function delete_on_master
|
||||||
Log "Propagating deletitions to master replica."
|
Log "Propagating deletitions to master replica."
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui -e \"$RSYNC_SSH_CMD\" $MASTER_DELETE --delete --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --include-from \"$MASTER_STATE_DIR/slave-deleted-list\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" \"$MASTER_SYNC_DIR/\" > /dev/shm/osync_deletition_on_master_$SCRIPT_PID 2>&1 &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui -e \"$RSYNC_SSH_CMD\" $MASTER_DELETE --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/slave-deleted-list\" --exclude=\"*\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" \"$MASTER_SYNC_DIR/\" > /dev/shm/osync_deletition_on_master_$SCRIPT_PID 2>&1 &"
|
||||||
else
|
else
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $MASTER_DELETE --delete --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --include-from \"$MASTER_STATE_DIR/slave-deleted-list\" \"$SLAVE_SYNC_DIR/\" \"$MASTER_SYNC_DIR/\" > /dev/shm/osync_deletition_on_master_$SCRIPT_PID 2>&1 &"
|
#rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $MASTER_DELETE --delete --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/master-deleted-list\" --include-from \"$MASTER_STATE_DIR/slave-deleted-list\" \"$SLAVE_SYNC_DIR/\" \"$MASTER_SYNC_DIR/\" > /dev/shm/osync_deletition_on_master_$SCRIPT_PID 2>&1 &"
|
||||||
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui $MASTER_DELETE --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/slave-deleted-list\" --exclude=\"*\" \"$SLAVE_SYNC_DIR/\" \"$MASTER_SYNC_DIR/\" > /dev/shm/osync_deletition_on_master_$SCRIPT_PID 2>&1 &"
|
||||||
fi
|
fi
|
||||||
if [ "$DEBUG" == "yes" ]
|
if [ "$DEBUG" == "yes" ]
|
||||||
then
|
then
|
||||||
|
@ -896,7 +902,7 @@ function delete_on_master
|
||||||
function master_tree_after
|
function master_tree_after
|
||||||
{
|
{
|
||||||
Log "Creating after run master replica file list."
|
Log "Creating after run master replica file list."
|
||||||
$(which $RSYNC_EXECUTABLE) --rsync-path="$RSYNC_PATH" -rlptgoDE --exclude "$OSYNC_DIR" --list-only "$MASTER_SYNC_DIR/" | grep "^-\|^d" | awk '{$1=$2=$3=$4="" ;print}' | awk '{$1=$1 ;print}' | (grep -v "^\.$" || :)> /dev/shm/osync_master-tree-after_$SCRIPT_PID &
|
$(which $RSYNC_EXECUTABLE) --rsync-path="$RSYNC_PATH" -rlptgoDE8 $RSYNC_ARGS --exclude "$OSYNC_DIR" $RSYNC_EXCLUDE --list-only "$MASTER_SYNC_DIR/" | grep "^-\|^d" | awk '{$1=$2=$3=$4="" ;print}' | awk '{$1=$1 ;print}' | (grep -v "^\.$" || :) | sort > /dev/shm/osync_master-tree-after_$SCRIPT_PID &
|
||||||
child_pid=$!
|
child_pid=$!
|
||||||
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME 0
|
WaitForCompletion $child_pid $SOFT_MAX_EXEC_TIME 0
|
||||||
retval=$?
|
retval=$?
|
||||||
|
@ -916,9 +922,9 @@ function slave_tree_after
|
||||||
Log "Creating after run slave replica file list."
|
Log "Creating after run slave replica file list."
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" --list-only $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) > /dev/shm/osync_slave-tree-after_$SCRIPT_PID &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS -e \"$RSYNC_SSH_CMD\" --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --list-only $REMOTE_USER@$REMOTE_HOST:\"$ESC_SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > /dev/shm/osync_slave-tree-after_$SCRIPT_PID &"
|
||||||
else
|
else
|
||||||
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE --exclude \"$OSYNC_DIR\" --list-only \"$SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) > /dev/shm/osync_slave-tree-after_$SCRIPT_PID &"
|
rsync_cmd="$(which $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" -rlptgoDE8 $RSYNC_ARGS --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --list-only \"$SLAVE_SYNC_DIR/\" | grep \"^-\|^d\" | awk '{\$1=\$2=\$3=\$4=\"\" ;print}' | awk '{\$1=\$1 ;print}' | (grep -v \"^\.$\" || :) | sort > /dev/shm/osync_slave-tree-after_$SCRIPT_PID &"
|
||||||
fi
|
fi
|
||||||
if [ "$DEBUG" == "yes" ]
|
if [ "$DEBUG" == "yes" ]
|
||||||
then
|
then
|
||||||
|
@ -1113,18 +1119,33 @@ function SoftDelete
|
||||||
if [ -d "$MASTER_BACKUP_DIR" ]
|
if [ -d "$MASTER_BACKUP_DIR" ]
|
||||||
then
|
then
|
||||||
Log "Removing backups older than $CONFLICT_BACKUP_DAYS days on master replica."
|
Log "Removing backups older than $CONFLICT_BACKUP_DAYS days on master replica."
|
||||||
find "$MASTER_BACKUP_DIR/" -ctime +$CONFLICT_BACKUP_DAYS | xargs rm -rf
|
if [ $dryrun -eq 1 ]
|
||||||
|
then
|
||||||
|
find "$MASTER_BACKUP_DIR/" -ctime +$CONFLICT_BACKUP_DAYS
|
||||||
|
else
|
||||||
|
find "$MASTER_BACKUP_DIR/" -ctime +$CONFLICT_BACKUP_DAYS | xargs rm -rf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
Log "Removing backups older than $CONFLICT_BACKUP_DAYS days on remote slave replica."
|
Log "Removing backups older than $CONFLICT_BACKUP_DAYS days on remote slave replica."
|
||||||
eval "$SSH_CMD \"if [ -d \\\"$SLAVE_BACKUP_DIR\\\" ]; then $COMMAND_SUDO find \\\"$SLAVE_BACKUP_DIR/\\\" -ctime +$CONFLICT_BACKUP_DAYS | xargs rm -rf; fi\""
|
if [ $dryrun -eq 1 ]
|
||||||
|
then
|
||||||
|
eval "$SSH_CMD \"if [ -d \\\"$SLAVE_BACKUP_DIR\\\" ]; then $COMMAND_SUDO find \\\"$SLAVE_BACKUP_DIR/\\\" -ctime +$CONFLICT_BACKUP_DAYS; fi\""
|
||||||
|
else
|
||||||
|
eval "$SSH_CMD \"if [ -d \\\"$SLAVE_BACKUP_DIR\\\" ]; then $COMMAND_SUDO find \\\"$SLAVE_BACKUP_DIR/\\\" -ctime +$CONFLICT_BACKUP_DAYS | xargs rm -rf; fi\""
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if [ -d "$SLAVE_BACKUP_DIR" ]
|
if [ -d "$SLAVE_BACKUP_DIR" ]
|
||||||
then
|
then
|
||||||
Log "Removing backups older than $CONFLICT_BACKUP_DAYS days on slave replica."
|
Log "Removing backups older than $CONFLICT_BACKUP_DAYS days on slave replica."
|
||||||
find "$SLAVE_BACKUP_DIR/" -ctime +$CONFLICT_BACKUP_DAYS | xargs rm -rf
|
if [ $dryrun -eq 1 ]
|
||||||
|
then
|
||||||
|
find "$SLAVE_BACKUP_DIR/" -ctime +$CONFLICT_BACKUP_DAYS
|
||||||
|
else
|
||||||
|
find "$SLAVE_BACKUP_DIR/" -ctime +$CONFLICT_BACKUP_DAYS | xargs rm -rf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1134,18 +1155,33 @@ function SoftDelete
|
||||||
if [ -d "$MASTER_DELETE_DIR" ]
|
if [ -d "$MASTER_DELETE_DIR" ]
|
||||||
then
|
then
|
||||||
Log "Removing soft deleted items older than $SOFT_DELETE_DAYS days on master replica."
|
Log "Removing soft deleted items older than $SOFT_DELETE_DAYS days on master replica."
|
||||||
find "$MASTER_DELETE_DIR/" -ctime +$SOFT_DELETE_DAYS | xargs rm -rf
|
if [ $dryrun -eq 1 ]
|
||||||
|
then
|
||||||
|
find "$MASTER_DELETE_DIR/" -ctime +$SOFT_DELETE_DAYS
|
||||||
|
else
|
||||||
|
find "$MASTER_DELETE_DIR/" -ctime +$SOFT_DELETE_DAYS | xargs rm -rf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
Log "Removing soft deleted items older than $SOFT_DELETE_DAYS days on remote slave replica."
|
Log "Removing soft deleted items older than $SOFT_DELETE_DAYS days on remote slave replica."
|
||||||
eval "$SSH_CMD \"if [ -d \\\"$SLAVE_DELETE_DIR\\\" ]; then $COMMAND_SUDO find \\\"$SLAVE_DELETE_DIR/\\\" -ctime +$SOFT_DELETE_DAYS | xargs rm -rf; fi\""
|
if [ $dryrun -eq 1 ]
|
||||||
|
then
|
||||||
|
eval "$SSH_CMD \"if [ -d \\\"$SLAVE_DELETE_DIR\\\" ]; then $COMMAND_SUDO find \\\"$SLAVE_DELETE_DIR/\\\" -ctime +$SOFT_DELETE_DAYS; fi\""
|
||||||
|
else
|
||||||
|
eval "$SSH_CMD \"if [ -d \\\"$SLAVE_DELETE_DIR\\\" ]; then $COMMAND_SUDO find \\\"$SLAVE_DELETE_DIR/\\\" -ctime +$SOFT_DELETE_DAYS | xargs rm -rf; fi\""
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if [ -d "$SLAVE_DELETE_DIR" ]
|
if [ -d "$SLAVE_DELETE_DIR" ]
|
||||||
then
|
then
|
||||||
Log "Removing soft deleted items older than $SOFT_DELETE_DAYS days on slave replica."
|
Log "Removing soft deleted items older than $SOFT_DELETE_DAYS days on slave replica."
|
||||||
find "$SLAVE_DELETE_DIR/" -ctime +$SOFT_DELETE_DAYS | xargs rm -rf
|
if [ $dryrun -eq 1 ]
|
||||||
|
then
|
||||||
|
find "$SLAVE_DELETE_DIR/" -ctime +$SOFT_DELETE_DAYS
|
||||||
|
else
|
||||||
|
find "$SLAVE_DELETE_DIR/" -ctime +$SOFT_DELETE_DAYS | xargs rm -rf
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue