Various bugfixes
This commit is contained in:
parent
7896a6ee46
commit
79818e2457
|
@ -11,16 +11,19 @@ FAR FUTURE IMPROVEMENTS
|
||||||
|
|
||||||
- Rethink of .osync_workdir/state/* files with PIDs, Host and Task Names to better identify multiple instances on the same fileset
|
- Rethink of .osync_workdir/state/* files with PIDs, Host and Task Names to better identify multiple instances on the same fileset
|
||||||
- Improve Master / Slave schema to Multimaster schema
|
- Improve Master / Slave schema to Multimaster schema
|
||||||
|
- State files should exist per replica for Multimaster schema
|
||||||
|
|
||||||
KNOWN ISSUES
|
KNOWN ISSUES
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- None yet, need more testing on MSYS environment
|
- None yet, need more testing on MSYS environment and MacOS X
|
||||||
|
|
||||||
RECENT CHANGES
|
RECENT CHANGES
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
- Various bugfixes introduced with function merge
|
||||||
- Added basic MacOS X support (yet not fully tested)
|
- Added basic MacOS X support (yet not fully tested)
|
||||||
|
- Merged tree list functions into one
|
||||||
- Added possibility to quick sync two local directories without any prior configuration
|
- Added possibility to quick sync two local directories without any prior configuration
|
||||||
- Added time control on OS detection
|
- Added time control on OS detection
|
||||||
- 02 Nov. 2013: Osync 0.99 RC2
|
- 02 Nov. 2013: Osync 0.99 RC2
|
||||||
|
|
100
osync.sh
100
osync.sh
|
@ -3,7 +3,7 @@
|
||||||
###### 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.99RC2
|
OSYNC_VERSION=0.99RC2
|
||||||
OSYNC_BUILD=1311201301
|
OSYNC_BUILD=1411201302
|
||||||
|
|
||||||
DEBUG=no
|
DEBUG=no
|
||||||
SCRIPT_PID=$$
|
SCRIPT_PID=$$
|
||||||
|
@ -263,6 +263,10 @@ function GetOperatingSystem
|
||||||
if [ $? != 0 ]
|
if [ $? != 0 ]
|
||||||
then
|
then
|
||||||
LOCAL_OS_VAR=$(uname -v 2>&1)
|
LOCAL_OS_VAR=$(uname -v 2>&1)
|
||||||
|
if [ $! != 0 ]
|
||||||
|
then
|
||||||
|
LOCAL_OS_VAR=($uname)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ]
|
||||||
then
|
then
|
||||||
|
@ -869,7 +873,7 @@ function UnlockDirectories
|
||||||
function tree_list
|
function tree_list
|
||||||
{
|
{
|
||||||
Log "Creating replica file list [$1]."
|
Log "Creating replica file list [$1]."
|
||||||
if [ "$REMOTE_SYNC" == "yes" ]
|
if [ "$REMOTE_SYNC" == "yes" ] && [[ "$2" == "slave"* ]]
|
||||||
then
|
then
|
||||||
CheckConnectivity3rdPartyHosts
|
CheckConnectivity3rdPartyHosts
|
||||||
CheckConnectivityRemoteHost
|
CheckConnectivityRemoteHost
|
||||||
|
@ -1236,13 +1240,13 @@ function Sync
|
||||||
if [ "$resume_sync" == "none" ] || [ "$resume_sync" == "noresume" ] || [ "$resume_sync" == "master-replica-tree.fail" ]
|
if [ "$resume_sync" == "none" ] || [ "$resume_sync" == "noresume" ] || [ "$resume_sync" == "master-replica-tree.fail" ]
|
||||||
then
|
then
|
||||||
#master_tree_current
|
#master_tree_current
|
||||||
tree_list $MASTER_SYNC_DIR master-tree-current master-replica-tree
|
tree_list "$MASTER_SYNC_DIR" master-tree-current master-replica-tree
|
||||||
resume_sync="resumed"
|
resume_sync="resumed"
|
||||||
fi
|
fi
|
||||||
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "master-replica-tree.success" ] || [ "$resume_sync" == "slave-replica-tree.fail" ]
|
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "master-replica-tree.success" ] || [ "$resume_sync" == "slave-replica-tree.fail" ]
|
||||||
then
|
then
|
||||||
#slave_tree_current
|
#slave_tree_current
|
||||||
tree_list $SLAVE_SYNC_DIR slave-tree-current slave-replica-tree
|
tree_list "$SLAVE_SYNC_DIR" slave-tree-current slave-replica-tree
|
||||||
resume_sync="resumed"
|
resume_sync="resumed"
|
||||||
fi
|
fi
|
||||||
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "slave-replica-tree.success" ] || [ "$resume_sync" == "master-replica-deleted-list.fail" ]
|
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "slave-replica-tree.success" ] || [ "$resume_sync" == "master-replica-deleted-list.fail" ]
|
||||||
|
@ -1295,72 +1299,16 @@ function Sync
|
||||||
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "delete-propagation-master.success" ] || [ "$resume_sync" == "master-replica-tree-after.fail" ]
|
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "delete-propagation-master.success" ] || [ "$resume_sync" == "master-replica-tree-after.fail" ]
|
||||||
then
|
then
|
||||||
#master_tree_after
|
#master_tree_after
|
||||||
tree_list $MASTER_SYNC_DIR master-tree-after master-replica-tree-after
|
tree_list "$MASTER_SYNC_DIR" master-tree-after master-replica-tree-after
|
||||||
resume_sync="resumed"
|
resume_sync="resumed"
|
||||||
fi
|
fi
|
||||||
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "master-replica-tree-after.success" ] || [ "$resume_sync" == "slave-replica-tree-after.fail" ]
|
if [ "$resume_sync" == "resumed" ] || [ "$resume_sync" == "master-replica-tree-after.success" ] || [ "$resume_sync" == "slave-replica-tree-after.fail" ]
|
||||||
then
|
then
|
||||||
#slave_tree_after
|
#slave_tree_after
|
||||||
tree_list $SLAVE_SYNC_DIR slave-tree-after slave-replica-tree-after
|
tree_list "$SLAVE_SYNC_DIR" slave-tree-after slave-replica-tree-after
|
||||||
resume_sync="resumed"
|
resume_sync="resumed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ## In this case statement, ;& means executing every command below regardless of conditions. Only works with bash v4
|
|
||||||
# case $resume_sync in
|
|
||||||
# none|noresume)
|
|
||||||
# ;&
|
|
||||||
# master-replica-tree.fail)
|
|
||||||
# master_tree_current
|
|
||||||
# ;&
|
|
||||||
# master-replica-tree.success|slave-replica-tree.fail)
|
|
||||||
# slave_tree_current
|
|
||||||
# ;&
|
|
||||||
# slave-replica-tree.success|master-replica-deleted-list.fail)
|
|
||||||
# master_delete_list
|
|
||||||
# ;&
|
|
||||||
# master-replica-deleted-list.success|slave-replica-deleted-list.fail)
|
|
||||||
# slave_delete_list
|
|
||||||
# ;&
|
|
||||||
# slave-replica-deleted-list.success|update-master-replica.fail|update-slave-replica.fail)
|
|
||||||
# if [ "$CONFLICT_PREVALANCE" != "master" ]
|
|
||||||
# then
|
|
||||||
# case $resume_sync in
|
|
||||||
# none)
|
|
||||||
# ;&
|
|
||||||
# slave-replica-deleted-list.success|update-master-replica.fail)
|
|
||||||
# sync_update_master
|
|
||||||
# ;&
|
|
||||||
# update-master-replica.success|update-slave-replica.fail)
|
|
||||||
# sync_update_slave
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
# else
|
|
||||||
# case $resume_sync in
|
|
||||||
# none)
|
|
||||||
# ;&
|
|
||||||
# slave-replica-deleted-list.success|update-slave-replica.fail)
|
|
||||||
# sync_update_slave
|
|
||||||
# ;&
|
|
||||||
# update-slave-replica.success|update-master-replica.fail)
|
|
||||||
# sync_update_master
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
# fi
|
|
||||||
# ;&
|
|
||||||
# update-slave-replica.success|update-master-replica.success|delete-propagation-slave.fail)
|
|
||||||
# delete_on_slave
|
|
||||||
# ;&
|
|
||||||
# delete-propagation-slave.success|delete-propagation-master.fail)
|
|
||||||
# delete_on_master
|
|
||||||
# ;&
|
|
||||||
# delete-propagation-master.success|master-replica-tree-after.fail)
|
|
||||||
# master_tree_after
|
|
||||||
# ;&
|
|
||||||
# master-replica-tree-after.success|slave-replica-tree-after.fail)
|
|
||||||
# slave_tree_after
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
|
|
||||||
Log "Finished synchronization task."
|
Log "Finished synchronization task."
|
||||||
echo "sync.success" > "$MASTER_STATE_DIR/last-action"
|
echo "sync.success" > "$MASTER_STATE_DIR/last-action"
|
||||||
echo "0" > "$MASTER_STATE_DIR/resume-count"
|
echo "0" > "$MASTER_STATE_DIR/resume-count"
|
||||||
|
@ -1554,6 +1502,25 @@ function Init
|
||||||
REMOTE_FIND_CMD=find
|
REMOTE_FIND_CMD=find
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Test if slave dir is a ssh uri, and if yes, break it down it its values
|
||||||
|
if [ "${SLAVE_SYNC_DIR:0:6}" == "ssh://" ]
|
||||||
|
then
|
||||||
|
slave_is_remote=1
|
||||||
|
|
||||||
|
# remove leadng 'ssh://'
|
||||||
|
uri=${SLAVE_SYNC_DIR#ssh://*}
|
||||||
|
# remove everything after '@'
|
||||||
|
uri2=${uri%@*}
|
||||||
|
user=${uri2%;*}
|
||||||
|
fingerprint=${uri2#*fingerprint=}
|
||||||
|
# remove everything before '@'
|
||||||
|
uri3=${uri#*@}
|
||||||
|
host=${uri3%%:*}
|
||||||
|
REMOTE_USER=${SLAVE_SYNC_DIR}
|
||||||
|
REMOTE_HOST=${SLAVE_SYNC_DIR}
|
||||||
|
REMOTE_PORT=${SLAVE_SYNC_DIR}
|
||||||
|
fi
|
||||||
|
|
||||||
## Rsync does not like spaces in directory names, considering it as two different directories. Handling this schema by escaping space
|
## Rsync does not like spaces in directory names, considering it as two different directories. Handling this schema by escaping space
|
||||||
## It seems this only happens when trying to execute an rsync command through eval $rsync_cmd... on a remote host. This is freaking unholy to find a workaround...
|
## It seems this only happens when trying to execute an rsync command through eval $rsync_cmd... on a remote host. This is freaking unholy to find a workaround...
|
||||||
## So actually use $MASTER_SYNC_DIR for local rsync calls and $ESC_MASTER_SYNC_DIR for remote rsync calls like user@host:$ESC_MASTER_SYNC_DIR
|
## So actually use $MASTER_SYNC_DIR for local rsync calls and $ESC_MASTER_SYNC_DIR for remote rsync calls like user@host:$ESC_MASTER_SYNC_DIR
|
||||||
|
@ -1681,7 +1648,7 @@ function Usage
|
||||||
{
|
{
|
||||||
echo "Osync $OSYNC_VERSION $OSYNC_BUILD"
|
echo "Osync $OSYNC_VERSION $OSYNC_BUILD"
|
||||||
echo ""
|
echo ""
|
||||||
echo "You may use Osync with a configuration file, or use its default options for quick command line sync."
|
echo "You may use Osync with a full blown configuration file, or use its default options for quick command line sync."
|
||||||
echo "Normal usage: osync /path/to/conf.file [--dry] [--silent] [--verbose] [--no-maxtime] [--force-unlock]"
|
echo "Normal usage: osync /path/to/conf.file [--dry] [--silent] [--verbose] [--no-maxtime] [--force-unlock]"
|
||||||
echo "Quick usage: osync --master=/path/to/master/replica --slave=/path/to/slave/replica [--dry] [--silent] [--verbose] [--no-max-time] [--force-unlock]"
|
echo "Quick usage: osync --master=/path/to/master/replica --slave=/path/to/slave/replica [--dry] [--silent] [--verbose] [--no-max-time] [--force-unlock]"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -1691,9 +1658,9 @@ function Usage
|
||||||
echo "--no-maxtime: disables any soft and hard execution time checks"
|
echo "--no-maxtime: disables any soft and hard execution time checks"
|
||||||
echo "--force-unlock: will override any existing active or dead locks on master and slave replica"
|
echo "--force-unlock: will override any existing active or dead locks on master and slave replica"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Quick usage:"
|
echo "Quick usage only:"
|
||||||
echo "--master= : Specify master replica path. Will contain state directory."
|
echo "--master= : Specify master replica path. Will contain state and backup directory."
|
||||||
echo "--slave= : Spacift slave replica path. Will contain state directory."
|
echo "--slave= : Spacift slave replica path. Will contain backup directory."
|
||||||
exit 128
|
exit 128
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1763,6 +1730,7 @@ then
|
||||||
REMOTE_SYNC=no
|
REMOTE_SYNC=no
|
||||||
CONFLICT_BACKUP_DAYS=30
|
CONFLICT_BACKUP_DAYS=30
|
||||||
SOFT_DELETE_DAYS=30
|
SOFT_DELETE_DAYS=30
|
||||||
|
RESUME_TRY=1
|
||||||
else
|
else
|
||||||
LoadConfigFile "$1"
|
LoadConfigFile "$1"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue