Monday 10 February 2020

How to Sync Local 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.rsync, source="/source_data_folder/", target="/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/ 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; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-02-10 21:46:32 IST; 7s ago
 Main PID: 2885 (lsyncd)
   CGroup: /system.slice/lsyncd.service
           └─2885 /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf

Feb 10 21:46:32 linuxcnf systemd[1]: Started Live Syncing (Mirror) Daemon.
[root@linuxcnf ~]#

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

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

No comments:

Post a Comment