Monday, 10 February 2020

How to Sync Local and Remote Directories using LSyncd on CentOS 7




LSyncd is free and open source tool that is designed to synchronize a slowly changing local files and folders to a local or remote target. It is sync changes or modification in a file and directory to the remote or local destination in a specific time interval.

This article describe How to Sync Local Directories using LSyncd on CentOS 7.

Step 1. Install Lsyncd package: Follow the article How to install lsyncd on CentOS 7 to install Lsyncd Package.

Step 2. Configuration Changes: Modify the LSyncd configuration file as shown below. Change the parameters according to the environment.

[root@linuxcnf ~]#
……………………..
--
settings{logfile = "/var/log/lsyncd/lsyncd.log",statusFile = "/var/log/lsyncd/lsyncd.status"}

sync{default.rsyncssh, source="/source_data_folder/", host = "target_host", targetdir="/target_folder/"}
[root@linuxcnf ~]#

Step 3. Starting Service: Run the following command to start the service and enable it for auto start across the machine reboot:

[root@linuxcnf ~]# systemctl start lsyncd
[root@linuxcnf ~]#

[root@linuxcnf ~]# systemctl enable lsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/lsyncd.service to /usr/lib/systemd/system/lsyncd.service.
[root@linuxcnf ~]#

Step 4. Verify the Service Status: Run the following command to verify Service Status:

[root@linuxcnf ~]# systemctl status lsyncd
lsyncd.service - Live Syncing (Mirror) Daemon
   Loaded: loaded (/usr/lib/systemd/system/lsyncd.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2020-02-10 22:16:40 IST; 4min 53s ago
 Main PID: 3715 (lsyncd)
   CGroup: /system.slice/lsyncd.service
           └─3715 /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf
……………………..
Feb 10 22:22:07 linuxcnf systemd[1]: Started Live Syncing (Mirror) Daemon.
[root@linuxcnf ~]#

[root@linuxcnf ~]# systemctl is-enabled lsyncd
enabled
[root@linuxcnf ~]#

Done!!! Check the log files status ("/var/log/lsyncd/lsyncd.log" and “/var/log/lsyncd/lsyncd.status").

No comments:

Post a comment