Download Unison and extract files to: C:Program Filesunison. Once configured, we can run the unison command in the master server to perform the sync.Ī simple approach to avoid manual synching is to use a cron task to schedule it every minute.Step 1: Download and Install OpenSSH. The sample file is self-descriptive but we can query the full documentation running man unison. When set to false a full-content comparison is used. When set to true, the size and the last modification time of the file are used to check if the file has changed. The purpose of the fastcheck option is to define which method must be used to check if a file should be updated.The auto and batch options must be used to avoid the user intervention when the sync process is performed.With the ignore options we can define path exclusions using globs or exact matches.The path option designate the paths inside the root that must be synched.Because we are using the SSH protocol in the remote root, we need to exchange ssh keys between slave and master. There must be exactly two: the local server path and the remote server path. The most important option to setup is the root of the paths to sync. The following gist shows the configuration of my master server: unison/default.prf and placed under the user’s home directory. Also, we can set those options using a configuration file. Unison provides an extensive set of CLI options that we can use to establish the sync configuration. Configuration must be set in the master, which is responsible for launching the sync process. Unison must be installed on both master and slave. In this scenario, one of the servers acts as the master and the other as the slave. To keep things safe we will use SSH tunnels to transfer the data. Once installed we can sync two servers connected over the internet. We must use the -batch CLI option to launch the tool in batch mode to skip user intervention. Once installed, we can sync two directories running the following command: unison -batch dir1 dir2 In OSX, we must use homebrew to perform the installation: brew install unison In order to use the binary from a terminal, we must place it in a directory included in the system path.Īlternatively, in a debian-like distribution, we can install the tool using apt: sudo apt-get -y install unison To install Unison we can download the precompiled binaries from here. Also, security is guaranteed because it can work over SSH tunnels. This tool works like rsync but it keeps stateful data supporting the bidirectional sync. It allows two replicas of a collection of files to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other. Unison is a file-sync tool for OSX, Unix, and Windows. There are several options to carry out this task, such as clustered file systems, but I have chosen a simple approach using Unison, a user-level tool that can be used to sync two replicas. This approach is simple and functional, but there is a problem: the sync must be bidirectional if we need to keep two identical replicas and avoid integrity issues. Until now, I was performing this task using the rsync tool and a cron task. Currently I am managing two little servers and I need to keep some data in sync.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |