Bugfixing...

pull/3/head
deajan 10 years ago
parent f2a74537ba
commit 6d677e26a2

@ -19,6 +19,8 @@ KNOWN ISSUES
RECENT CHANGES RECENT CHANGES
-------------- --------------
- Fixed a bug preventing propagation of empty directory deletions
- Fixed a nasty bug preventing writing lock files on remote system as superuser
- Gzipped logs are now deleted once sent - Gzipped logs are now deleted once sent
- Fixed some typos (thanks to Pavel Kiryukhin) - Fixed some typos (thanks to Pavel Kiryukhin)
- Added a simple RHEL / CentOS compatible init script - Added a simple RHEL / CentOS compatible init script

@ -4,7 +4,7 @@ PROGRAM="Osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong" AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=0.99preRC3 PROGRAM_VERSION=0.99preRC3
PROGRAM_BUILD=2303201401 PROGRAM_BUILD=2303201403
DEBUG=no DEBUG=no
SCRIPT_PID=$$ SCRIPT_PID=$$
@ -45,7 +45,7 @@ export LC_ALL=C
function Log function Log
{ {
if [ $sync_on_changes -eq 1 ] || [ $daemonize -eq 1 ] if [ $sync_on_changes -eq 1 ]
then then
prefix="$(date) - " prefix="$(date) - "
else else
@ -232,7 +232,7 @@ function SendAlert
return 1 return 1
fi fi
if -f $RUN_DIR/osync_lastlog.gz if [ -f $RUN_DIR/osync_lastlog.gz ]
then then
rm $RUN_DIR/osync_lastlog.gz rm $RUN_DIR/osync_lastlog.gz
fi fi
@ -345,6 +345,10 @@ function GetOperatingSystem
*"Darwin"*) *"Darwin"*)
REMOTE_OS="MacOSX" REMOTE_OS="MacOSX"
;; ;;
"ssh"*)
LogError "Cannot connect to remote system."
exit 1
;;
*) *)
LogError "Running on remote >> $REMOTE_OS_VAR << not supported. Please report to the author." LogError "Running on remote >> $REMOTE_OS_VAR << not supported. Please report to the author."
exit 1 exit 1
@ -746,7 +750,7 @@ function WriteLockFiles
then then
CheckConnectivity3rdPartyHosts CheckConnectivity3rdPartyHosts
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
eval "$SSH_CMD \"$COMMAND_SUDO echo $SCRIPT_PID@$SYNC_ID > \\\"$SLAVE_LOCK\\\"\"" & eval "$SSH_CMD \"echo $SCRIPT_PID@$SYNC_ID | $COMMAND_SUDO tee \\\"$SLAVE_LOCK\\\" > /dev/null \"" &
child_pid=$! child_pid=$!
WaitForTaskCompletion $child_pid 0 1800 WaitForTaskCompletion $child_pid 0 1800
if [ $? != 0 ] if [ $? != 0 ]
@ -990,12 +994,12 @@ function sync_update
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
if [ "$1" == "master" ] if [ "$1" == "master" ]
then then
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $BACKUP_DIR --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/$1-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/$2-deleted-list\" \"$SOURCE_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_DEST_DIR/\" > $RUN_DIR/osync_update_$2_replica_$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $BACKUP_DIR --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --exclude-from=\"$MASTER_STATE_DIR/$2-deleted-list\" \"$SOURCE_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_DEST_DIR/\" > $RUN_DIR/osync_update_$2_replica_$SCRIPT_PID 2>&1 &"
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $BACKUP_DIR --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/$1-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/$2-deleted-list\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SOURCE_DIR/\" \"$DEST_DIR/\" > $RUN_DIR/osync_update_$2_replica_$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $BACKUP_DIR --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --exclude-from=\"$MASTER_STATE_DIR/$2-deleted-list\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SOURCE_DIR/\" \"$DEST_DIR/\" > $RUN_DIR/osync_update_$2_replica_$SCRIPT_PID 2>&1 &"
fi fi
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats $BACKUP_DIR --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from \"$MASTER_STATE_DIR/$1-deleted-list\" --exclude-from \"$MASTER_STATE_DIR/$2-deleted-list\" \"$SOURCE_DIR/\" \"$DEST_DIR/\" > $RUN_DIR/osync_update_$2_replica_$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats $BACKUP_DIR --exclude \"$OSYNC_DIR\" $RSYNC_EXCLUDE --exclude-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --exclude-from=\"$MASTER_STATE_DIR/$2-deleted-list\" \"$SOURCE_DIR/\" \"$DEST_DIR/\" > $RUN_DIR/osync_update_$2_replica_$SCRIPT_PID 2>&1 &"
fi fi
LogDebug "RSYNC_CMD: $rsync_cmd" LogDebug "RSYNC_CMD: $rsync_cmd"
eval "$rsync_cmd" eval "$rsync_cmd"
@ -1046,12 +1050,13 @@ function deletion_propagation
CheckConnectivityRemoteHost CheckConnectivityRemoteHost
if [ "$1" == "master" ] if [ "$1" == "master" ]
then then
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"-! */\" \"$SOURCE_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_DEST_DIR/\" > $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &" #rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"-! */\" \"$SOURCE_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_DEST_DIR/\" > $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &"
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"- *\" \"$SOURCE_DIR/\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_DEST_DIR/\" > $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &"
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"-! */\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SOURCE_DIR/\" \"$DEST_DIR/\"> $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats -e \"$RSYNC_SSH_CMD\" $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"- *\" $REMOTE_USER@$REMOTE_HOST:\"$ESC_SOURCE_DIR/\" \"$DEST_DIR/\"> $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &"
fi fi
else else
rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from \"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"-! */\" \"$SOURCE_DIR/\" \"$DEST_DIR/\" > $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &" rsync_cmd="$(type -p $RSYNC_EXECUTABLE) --rsync-path=\"$RSYNC_PATH\" $RSYNC_ARGS -rlptgoDEui --stats $DELETE_DIR --delete --exclude \"$OSYNC_DIR\" --include-from=\"$MASTER_STATE_DIR/$1-deleted-list\" --filter=\"- *\" \"$SOURCE_DIR/\" \"$DEST_DIR/\" > $RUN_DIR/osync_deletion_on_$2_$SCRIPT_PID 2>&1 &"
fi fi
LogDebug "RSYNC_CMD: $rsync_cmd" LogDebug "RSYNC_CMD: $rsync_cmd"
eval "$rsync_cmd" eval "$rsync_cmd"
@ -1632,7 +1637,6 @@ error_alert=0
soft_stop=0 soft_stop=0
quick_sync=0 quick_sync=0
sync_on_changes=0 sync_on_changes=0
daemonize=0
nolocks=0 nolocks=0
osync_cmd=$0 osync_cmd=$0
@ -1686,9 +1690,6 @@ do
--on-changes) --on-changes)
sync_on_changes=1 sync_on_changes=1
;; ;;
--daemon)
daemonize=1
;;
--no-locks) --no-locks)
nolocks=1 nolocks=1
;; ;;
@ -1717,25 +1718,12 @@ then
Init Init
if [ $sync_on_changes -eq 1 ] if [ $sync_on_changes -eq 1 ]
then then
if [ $daemonize -eq 1 ] SyncOnChanges
then
silent=1
exec > /dev/null 2>&1
SyncOnChanges &
disown
exit 0
else
SyncOnChanges
fi
else else
DATE=$(date) DATE=$(date)
Log "-------------------------------------------------------------" Log "-------------------------------------------------------------"
Log "$DRY_WARNING $DATE - $PROGRAM $PROGRAM_VERSION script begin." Log "$DRY_WARNING $DATE - $PROGRAM $PROGRAM_VERSION script begin."
Log "-------------------------------------------------------------" Log "-------------------------------------------------------------"
if [ $daemonize -eq 1 ]
then
Log "Running as daemon"
fi
Log "Sync task [$SYNC_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" Log "Sync task [$SYNC_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)"
GetOperatingSystem GetOperatingSystem
if [ $no_maxtime -eq 1 ] if [ $no_maxtime -eq 1 ]

@ -2,7 +2,7 @@
###### Osync - Rsync based two way sync engine with fault tolerance ###### Osync - Rsync based two way sync engine with fault tolerance
###### (L) 2013-2014 by Orsiris "Ozy" de Jong (www.netpower.fr) ###### (L) 2013-2014 by Orsiris "Ozy" de Jong (www.netpower.fr)
###### Config file rev 0903201401 ###### Config file rev 2303201401
## ---------- GENERAL OPTIONS ## ---------- GENERAL OPTIONS
@ -13,8 +13,8 @@ SYNC_ID="sync_test"
MASTER_SYNC_DIR="/home/git/osync/test/dir1" MASTER_SYNC_DIR="/home/git/osync/test/dir1"
#SLAVE_SYNC_DIR="/home/git/osync/test/dir2" #SLAVE_SYNC_DIR="/home/git/osync/test/dir2"
SLAVE_SYNC_DIR=""ssh://user@host.com:22//path/to/dir2" SLAVE_SYNC_DIR=""ssh://user@host.com:22//path/to/dir2"
## If slave replica is a remote directory, you must specifiy a RSA key. Please see documentation for further information. ## If slave replica is a remote directory, you must specifiy a RSA key (please use full path). Please see documentation for further information.
SSH_RSA_PRIVATE_KEY="~/.ssh/id_rsa" SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
## Create sync directories if they do not exist ## Create sync directories if they do not exist
CREATE_DIRS=no CREATE_DIRS=no

Loading…
Cancel
Save