Unison File Synchronizer
In my previous artical I use to mentions one tool call CSYNC2 (Cluster Synchronization Tool).
After using this tool for a while there are some more features that I need but this tool could not show it up.
For I now I try to set and other tool up call: Unison File Synchronizer
Which is an other File Synchronizer tool, That I going to mention and show what I tried and work as what I exspected:
That provide 2 ways synchroinzations between nodes and we also could exclude (ignore) the folder that we don't want to sync also.
Here is a sample structure sync:
Install in Ubuntu server:
apt-get install unison
There are many different ways of using this tool. In this purpose I am going to sync between 2 servers. (they are cluster-servers)
After Installed,
Make sure these 2 node can automatically log in into each other with using password:
by using key. If you not sure how to check it out from here:
After complete this step,
1. Log in as root on server1 and edit a default profile file:
vi /root/.unison/default.prf
with content:
---------------------------------------------------
# Unison preferences file
include userone
include usertwo
root = /home
root = ssh://server2//home
auto=true
batch=true
confirmbigdel=true
fastcheck=true
group=true
owner=true
prefer=newer
silent=true
times=true
2. Edit file userone
vi /root/.unison/userone
with content:
---------------------------------------------------
# Paths to synchronize
path = userone/public_html
# Ignore
ignore = Path userone/public_html/foldertemp/*
3. Edit file usertwo
vi /root/.unison/usertwo
with content:
---------------------------------------------------
# Paths to synchronize
path = usertwo/public_html
# Ignore
ignore = Path usertwo/public_html/foldertemp/*
---------------------------------------------------
Now that we have put all settings in a preferences file (especially the root (and optionally the path) directives), we can run Unison without any arguments:
unison
Or,
We should run this in cron in every 2 minutes:
crontab -e
*/2 * * * * /usr/bin/unison &> /dev/null
In this example will sync 2 ways between public_html and ignore /public_html/foldertemp in home users:
userone and usertwo between server1 and server2.
Note:
* Unison will check configurations in its users run the command, in folder name ~/.unison
* In file /root/.unison/default.prf has the option include filename
(we can include as many files as we one with those filename that contain the path we want to sync.)
* We can include the path as many as we want.
For more info: http://www.cis.upenn.edu/~bcpierce/unison/lists.html
No comments:
Post a Comment