2
0
mirror of https://github.com/deajan/osync synced 2024-11-19 03:25:37 +00:00
osync/README.md

121 lines
6.4 KiB
Markdown
Raw Normal View History

2014-05-27 11:00:52 +00:00
osync 0.99RC3
=============
2013-06-18 10:56:16 +00:00
2014-05-27 11:00:52 +00:00
A two way sync script with fault tolerance, resuming, deletion backup and conflict backups.
2013-06-18 11:02:41 +00:00
## About
2013-11-02 20:57:15 +00:00
I searched for a nice tool to handle two (or more) way sync scenarios in a reliable way, easy to use and automate.
2014-05-27 11:00:52 +00:00
While unison does the job, it's not very pretty to configure, slow, won't handle ACLs and won't automatically resume if something bad happened.
2013-07-24 19:13:15 +00:00
Then i read about bitpocket, a nice script provided by Marcin Kulik (sickill) at https://github.com/sickill/bitpocket.git
2013-07-24 19:03:58 +00:00
Bitpocked inspired me to write my own implementation of a two way sync script, implementing features i wanted among:
2013-07-24 19:13:15 +00:00
2013-11-02 20:57:15 +00:00
- Fault tolerance with resume scenarios
- Email alerts
2013-07-24 19:13:15 +00:00
- Logging facility
- Soft deletition and multiple backups handling
- Before / after command execution
- Time control
2014-01-19 19:31:14 +00:00
- Directory monitoring
- Running on schedule or as daemon
2013-07-24 19:03:58 +00:00
2014-01-19 19:31:14 +00:00
Osync uses a master / slave sync schema. It can sync local to local or local to remote directories. By definition, master replica should always be a local directory on the system osync runs on.
2013-07-24 19:03:58 +00:00
Also, osync uses pidlocks to prevent multiple concurrent sync processes on/to the same master / slave replica. Be sure a sync process is finished before launching next one.
You may launch concurrent sync processes on the same system but only for different master replicas.
2013-06-18 11:02:41 +00:00
2014-05-27 11:00:52 +00:00
Currently, it has been tested on CentOS 5, CentOS 6, Debian 6.0.7, Linux Mint 14, 15 and 16, Ubuntu 12.04 and Ubuntu 12.10, and FreeBSD 8.3.
Some users report MacOS X to work good, but some tests are still needed.
Windows is supported via MSYS environment.
2013-06-18 11:02:41 +00:00
## Installation
2013-07-24 19:03:58 +00:00
Keep in mind that Osync has been designed to not delete any data, but rather make backups or soft deletes.
2014-05-21 17:12:19 +00:00
Nevertheless, you should always consider making backups of your data before trying a new sync tool.
2013-07-24 19:03:58 +00:00
2014-05-21 17:12:19 +00:00
You can download the latest stable release of Osync at www.netpower.fr/osync
2014-05-27 11:00:52 +00:00
You may also get the last development snapshot at https://github.com/deajan/osync with the following command
$ git clone https://github.com/deajan/osync
2013-07-24 19:13:15 +00:00
2014-05-21 17:12:19 +00:00
You may copy the osync.sh file to /usr/local/bin if you intend to use it on a regular basis, or just run it from the directory you downloaded it to.
2014-05-27 11:00:52 +00:00
There is also a very basic installation script if you plan to use osync as a daemon too.
2013-07-24 19:03:58 +00:00
2014-05-21 17:12:19 +00:00
Osync needs to run with bash shell. Using any other shell will most probably result in errors.
2014-05-27 11:00:52 +00:00
If bash is not your default shell, you may invoke it using
2014-01-19 19:31:14 +00:00
$ bash osync.sh [options]
2013-07-24 19:03:58 +00:00
## Usage
2014-05-27 11:00:52 +00:00
Osync can work with in three flavors: Quick sync mode, configuration file mode, and daemon mode.
2013-11-03 19:29:17 +00:00
While quick sync mode is convenient to do fast sync sceanrios, a configuration file gives much more functionnality.
2014-05-21 17:12:19 +00:00
Please use double as directoires delimiters. Do not use escaped characters in directory names.
2013-11-03 19:29:17 +00:00
2014-05-27 11:00:52 +00:00
QuickSync example
-----------------
2014-01-19 19:31:14 +00:00
$ ./osync.sh --master="/path/to/dir1" --slave="/path/to/remote dir2"
$ ./osync.sh --master="/path/to/another dir" --slave="ssh://user@host.com:22//path/to/dir2" --rsakey=/home/user/.ssh/id_rsa
2013-11-03 19:29:17 +00:00
2014-05-27 11:00:52 +00:00
Configuration files example
---------------------------
2013-11-03 19:29:17 +00:00
You'll have to customize the sync.conf file according to your needs.
2014-05-21 17:12:19 +00:00
If you intend to sync a remote directory, osync will need a pair of private / public RSA keys to perform remote SSH connections.
2013-11-03 19:29:17 +00:00
Also, running sync as superuser requires to configure /etc/sudoers file.
2014-05-21 17:12:19 +00:00
Please read the documentation about remote sync setups.
2013-11-02 20:57:15 +00:00
Once you've customized a sync.conf file, you may run osync with the following test run:
2013-07-24 19:03:58 +00:00
$ ./osync.sh /path/to/your.conf --dry
If everything went well, you may run the actual configuration with one of the following:
$ ./osync.sh /path/to/your.conf
$ ./osync.sh /path/to/your.conf --verbose
$ ./osync.sh /path/to/your.conf --no-maxtime
2013-07-24 19:03:58 +00:00
Verbose option will display which files and attrs are actually synchronized.
2014-11-29 14:07:09 +00:00
You may mix "--silent" and "--verbose" parameters to output verbose input only in the log files.
No-Maxtime option will disable execution time checks, which is usefull for big initial sync tasks that might take long time. Next runs should then only propagate changes and take much less time.
2014-01-19 19:31:14 +00:00
Once you're confident about your fist runs, you may add osync as cron task like the following in /etc/crontab which would run osync every 5 minutes:
2013-07-24 19:03:58 +00:00
2014-01-19 19:31:14 +00:00
*/5 * * * * root /usr/local/bin/osync.sh /path/to/your.conf --silent
2013-07-24 19:03:58 +00:00
2014-11-26 10:28:35 +00:00
Batch mode
----------
You may want to sequentially run multiple sync sets between the same servers. In that case, osync-batch.sh is a nice tool that will run every osync conf file, and, if a task fails,
run it again if there's still some time left.
The following example will run all .conf files found in /etc/osync, and retry 3 times every configuration that fails, if the whole sequential run took less than 2 hours.
$ ./osync-batch.sh --path=/etc/osync --max-retries=3 --max-exec-time=7200
Having multiple conf files can then be run in a single cron command like
00 00 * * * root /usr/local/bin/osync-batch.sh --path=/etc/osync --silent
2014-05-27 11:00:52 +00:00
Daemon mode
-----------
2013-11-18 21:44:20 +00:00
Additionnaly, you may run osync in monitor mode, which means it will perform a sync upon file operations on master replica.
2014-05-21 17:12:19 +00:00
This can be a drawback on functionnality versus scheduled mode because this mode only launches a sync task if there are file modifications on the master replica, without being able to monitor the slave replica. Slave replica changes are then only synced when master replica changes occur.
File monitor mode can also be launched as a daemon with an init script. Please read the documentation for more info.
2013-11-25 12:24:55 +00:00
Note that monitoring changes requires inotifywait command (inotify-tools package for most Linux distributions).
2014-05-27 11:00:52 +00:00
BSD, MacOS X and Windows are not yet supported for this operation mode, unless you find a inotify-tools package on these OSes.
2013-11-18 21:44:20 +00:00
$ ./osync.sh /path/to/your.conf --on-changes
2014-05-21 17:12:19 +00:00
Osync file monitor mode may be run as system service with the osync-srv init script. Any configuration file found in /etc/osync will then create a osync daemon instance.
2014-05-27 11:00:52 +00:00
You may run the install.sh script which should work in most cases or copy the files by hand (osync.sh to /usr/bin/local, osync-srv to /etc/init.d, sync.conf to /etc/osync).
2013-11-18 21:44:20 +00:00
2014-05-21 17:12:19 +00:00
$ service osync-srv start
2014-05-27 11:00:52 +00:00
Troubleshooting
---------------
2014-05-21 17:12:19 +00:00
You may find osync's logs in /var/log/osync-*.log (or current directory if /var/log is not writable).
2014-05-27 11:00:52 +00:00
Additionnaly, you can use the --verbose flag see to what actions are going on.
2013-06-18 11:02:41 +00:00
## Author
2013-07-24 19:03:58 +00:00
Feel free to mail me for limited support in my free time :)
Orsiris "Ozy" de Jong | ozy@netpower.fr