Added ssh uri support
This commit is contained in:
parent
941f8bb749
commit
13420e6d83
|
@ -4,7 +4,6 @@ SHORT FUTURE IMPROVEMENTS (post v1.0)
|
||||||
- Sync and delete propagation function merge (master and slave functions are the same, reduces code size and maintain effort)
|
- Sync and delete propagation function merge (master and slave functions are the same, reduces code size and maintain effort)
|
||||||
- Tree function merge (current and after tree functions are the same except for output filename and logging, reduces code size and maintain effort)
|
- Tree function merge (current and after tree functions are the same except for output filename and logging, reduces code size and maintain effort)
|
||||||
- Tree functions execute piped commands (grep, awk) on master when launched on remote slave which can cause more bandwith usage
|
- Tree functions execute piped commands (grep, awk) on master when launched on remote slave which can cause more bandwith usage
|
||||||
- Fast sync mode should also work with remote systems
|
|
||||||
|
|
||||||
FAR FUTURE IMPROVEMENTS
|
FAR FUTURE IMPROVEMENTS
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -21,6 +20,8 @@ KNOWN ISSUES
|
||||||
RECENT CHANGES
|
RECENT CHANGES
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
- Changed conf file default format for ssh uri (old format is still compatible)
|
||||||
|
- Added ssh uri support for slave replicas
|
||||||
- Improved execution hooks logs
|
- Improved execution hooks logs
|
||||||
- Various bugfixes introduced with function merge
|
- Various bugfixes introduced with function merge
|
||||||
- Added basic MacOS X support (yet not fully tested)
|
- Added basic MacOS X support (yet not fully tested)
|
||||||
|
|
|
@ -47,6 +47,7 @@ While quick sync mode is convenient to do fast sync sceanrios, a configuration f
|
||||||
QuickSync example:
|
QuickSync example:
|
||||||
|
|
||||||
$ ./osync.sh --master=/path/to/dir1 --slave=/path/to/dir2
|
$ ./osync.sh --master=/path/to/dir1 --slave=/path/to/dir2
|
||||||
|
$ ./osync.sh --master=/path/to/dir1 --slave=ssh://user@host.com:22//path/to/dir2 --rsakey=/home/user/.ssh/id_rsa
|
||||||
|
|
||||||
Configuration files example:
|
Configuration files example:
|
||||||
|
|
||||||
|
|
40
osync.sh
40
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.99RC2
|
OSYNC_VERSION=0.99RC2-qs
|
||||||
OSYNC_BUILD=1611201301
|
OSYNC_BUILD=1811201301
|
||||||
|
|
||||||
DEBUG=no
|
DEBUG=no
|
||||||
SCRIPT_PID=$$
|
SCRIPT_PID=$$
|
||||||
|
@ -1505,20 +1505,30 @@ function Init
|
||||||
## Test if slave dir is a ssh uri, and if yes, break it down it its values
|
## Test if slave dir is a ssh uri, and if yes, break it down it its values
|
||||||
if [ "${SLAVE_SYNC_DIR:0:6}" == "ssh://" ]
|
if [ "${SLAVE_SYNC_DIR:0:6}" == "ssh://" ]
|
||||||
then
|
then
|
||||||
slave_is_remote=1
|
REMOTE_SYNC="yes"
|
||||||
|
|
||||||
# remove leadng 'ssh://'
|
# remove leadng 'ssh://'
|
||||||
uri=${SLAVE_SYNC_DIR#ssh://*}
|
uri=${SLAVE_SYNC_DIR#ssh://*}
|
||||||
# remove everything after '@'
|
# remove everything after '@'
|
||||||
uri2=${uri%@*}
|
_first_part=${uri%@*}
|
||||||
user=${uri2%;*}
|
REMOTE_USER=${_first_part%;*}
|
||||||
fingerprint=${uri2#*fingerprint=}
|
#fingerprint=${_first_part#*fingerprint=}
|
||||||
|
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]
|
||||||
|
then
|
||||||
|
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
|
||||||
|
fi
|
||||||
# remove everything before '@'
|
# remove everything before '@'
|
||||||
uri3=${uri#*@}
|
_last_part=${uri#*@}
|
||||||
host=${uri3%%:*}
|
_last_part2=${_last_part%%/*}
|
||||||
REMOTE_USER=${SLAVE_SYNC_DIR}
|
# remove last part if no port defined
|
||||||
REMOTE_HOST=${SLAVE_SYNC_DIR}
|
REMOTE_HOST=${_last_part2%%:*}
|
||||||
REMOTE_PORT=${SLAVE_SYNC_DIR}
|
if [[ "$_last_part2" == *":"* ]]
|
||||||
|
then
|
||||||
|
REMOTE_PORT=${_last_part2##*:}
|
||||||
|
else
|
||||||
|
REMOTE_PORT=22
|
||||||
|
fi
|
||||||
|
SLAVE_SYNC_DIR=${_last_part#*/}
|
||||||
fi
|
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
|
||||||
|
@ -1650,7 +1660,7 @@ function Usage
|
||||||
echo ""
|
echo ""
|
||||||
echo "You may use Osync with a full blown 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 [--rsakey=/path/to/id_rsa] [--dry] [--silent] [--verbose] [--no-max-time] [--force-unlock]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "--dry: will run osync without actually doing anything; just testing"
|
echo "--dry: will run osync without actually doing anything; just testing"
|
||||||
echo "--silent: will run osync without any output to stdout, usefull for cron jobs"
|
echo "--silent: will run osync without any output to stdout, usefull for cron jobs"
|
||||||
|
@ -1660,7 +1670,8 @@ function Usage
|
||||||
echo ""
|
echo ""
|
||||||
echo "Quick usage only:"
|
echo "Quick usage only:"
|
||||||
echo "--master= : Specify master replica path. Will contain state and backup directory."
|
echo "--master= : Specify master replica path. Will contain state and backup directory."
|
||||||
echo "--slave= : Spacift slave replica path. Will contain backup directory."
|
echo "--slave= : Specify local or remote path for slave replica. Can be a ssh uri like ssh://user@host.com:22//path/to/slave/replica"
|
||||||
|
echo "--rsakey= : Specify alternative path to rsa private key for ssh connection to slave replica."
|
||||||
exit 128
|
exit 128
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1717,6 +1728,9 @@ do
|
||||||
SLAVE_SYNC_DIR=${i##*=}
|
SLAVE_SYNC_DIR=${i##*=}
|
||||||
no_maxtime=1
|
no_maxtime=1
|
||||||
;;
|
;;
|
||||||
|
--rsakey=*)
|
||||||
|
SSH_RSA_PRIVATE_KEY=${i##*=}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue