Added ssh uri support

pull/3/head
deajan 11 years ago
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)
- 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
- Fast sync mode should also work with remote systems
FAR FUTURE IMPROVEMENTS
-----------------------
@ -21,6 +20,8 @@ KNOWN ISSUES
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
- Various bugfixes introduced with function merge
- 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:
$ ./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:

@ -2,8 +2,8 @@
###### Osync - Rsync based two way sync engine with fault tolerance
###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
OSYNC_VERSION=0.99RC2
OSYNC_BUILD=1611201301
OSYNC_VERSION=0.99RC2-qs
OSYNC_BUILD=1811201301
DEBUG=no
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
if [ "${SLAVE_SYNC_DIR:0:6}" == "ssh://" ]
then
slave_is_remote=1
REMOTE_SYNC="yes"
# remove leadng 'ssh://'
uri=${SLAVE_SYNC_DIR#ssh://*}
# remove everything after '@'
uri2=${uri%@*}
user=${uri2%;*}
fingerprint=${uri2#*fingerprint=}
_first_part=${uri%@*}
REMOTE_USER=${_first_part%;*}
#fingerprint=${_first_part#*fingerprint=}
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]
then
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
fi
# remove everything before '@'
uri3=${uri#*@}
host=${uri3%%:*}
REMOTE_USER=${SLAVE_SYNC_DIR}
REMOTE_HOST=${SLAVE_SYNC_DIR}
REMOTE_PORT=${SLAVE_SYNC_DIR}
_last_part=${uri#*@}
_last_part2=${_last_part%%/*}
# remove last part if no port defined
REMOTE_HOST=${_last_part2%%:*}
if [[ "$_last_part2" == *":"* ]]
then
REMOTE_PORT=${_last_part2##*:}
else
REMOTE_PORT=22
fi
SLAVE_SYNC_DIR=${_last_part#*/}
fi
## 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 "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 "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 "--dry: will run osync without actually doing anything; just testing"
echo "--silent: will run osync without any output to stdout, usefull for cron jobs"
@ -1660,7 +1670,8 @@ function Usage
echo ""
echo "Quick usage only:"
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
}
@ -1717,6 +1728,9 @@ do
SLAVE_SYNC_DIR=${i##*=}
no_maxtime=1
;;
--rsakey=*)
SSH_RSA_PRIVATE_KEY=${i##*=}
;;
esac
done

Loading…
Cancel
Save