Automating Remote File Synchronization with Sersync and Rsync on CentOS

Implementing Real-time File Synchronization with Sersync and Rsync

This guide details the implementation of a real-time file synchronization solution using Sersync and Rsync on CentOS systems. This setup allows for automatic synchronizasion of local file modifications to a remote directory, making it ideal for backup solutions and content mirroring.

Architecture Overview

The synchronization solution consists of two main components:

  • Sersync: Installed on the source server, monitors file system changes and triggers synchronization
  • Rsync: Runs as a daemon on both source and destination servers to handle the actual file transfer

In this configuration, the source server runs the Sersync service, which detects file changes and uses Rsync to push files to the destination server running the Rsync daemon. This approach is commonly used for data synchronization, backup solutions, and web content mirroring.

System Requirements

  • CentOS 6.5 (x86_64 architecture)
  • Rsync package installed on both systems
  • Sersync 2.5 binary for 64-bit systems
  • Source server: 192.168.1.10 (example IP)
  • Destination server: 192.168.1.20 (example IP)

The goal is to synchronize files from a directory on the source server to a corresponding directory on the destination server, maintaining identical content on both systems. Both servers must have Rsync installed with appropriate write permissions.

Configuration Steps

Destination Server Setup

1. Verify Rsync Installation

[root@dest-server ~]# rpm -qa | grep rsync
rsync-3.0.6-4.el6_7.1

If not installed, use yum to install it:

[root@dest-server ~]# yum install -y rsync

2. Configure Rsync Daemon

Create the configuration file at /etc/rsyncd.conf:

uid = root
gid = root
use chroot = no
list = no
log file = /var/log/rsyncd.log
[data_sync]
path = /var/backups/sync_data
comment = Data synchronization directory
ignore errors
read only = no
list = no
max connections = 200
timeout = 600
auth users = syncuser
secrets file = /etc/rsync.secrets
hosts allow = 192.168.1.0/24

Key configuration elements:

  • secrets file: Path to the authentication credentials file
  • [data_sync]: Module name used for synchronization
  • path: Directory to receive synchronized files
  • hosts allow: IP addresses permited to connect (in this case, the source server's subnet)

3. Create Authentication File

Create and secure the credentials file:

[root@dest-server ~]# echo "syncuser:securePassword123" > /etc/rsync.secrets
[root@dest-server ~]# chmod 600 /etc/rsync.secrets

4. Create Synchronization Directory

[root@dest-server ~]# mkdir -p /var/backups/sync_data

5. Start Rsync Daemon

[root@dest-server ~]# rsync --daemon --config=/etc/rsyncd.conf
[root@dest-server ~]# ps aux | grep rsync
root     12345     1  0 14:30 ?        00:00:00 rsync --daemon --config=/etc/rsyncd.conf

Restart the xinetd service to apply configuration changes:

[root@dest-server ~]# service xinetd restart

6. Configure System Startup

[root@dest-server ~]# echo "rsync --daemon --config=/etc/rsyncd.conf" >> /etc/rc.d/rc.local

Source Server Setup

1. Download and Install Sersync

[root@src-server ~]# wget --no-check-certificate https://github.com/orangle/sersync/raw/master/release/sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@src-server ~]# mkdir -p /usr/local/sersync/{conf,bin,log}
[root@src-server ~]# tar xzf sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@src-server ~]# cd GNU-Linux-x86/
[root@src-server ~]# cp confxml.xml /usr/local/sersync/conf/
[root@src-server ~]# cp sersync2 /usr/local/sersync/bin/

2. Create Authentication File

Create a password file (username not needed here):

[root@src-server ~]# echo "securePassword123" > /etc/rsync.secrets
[root@src-server ~]# chmod 600 /etc/rsync.secrets

3. Configure Sersync

Edit the configuration file at /usr/local/sersync/conf/confxml.xml:

<?xml version="1.0" encoding="ISO-8859-1"??>

   <host hostip="192.168.1.10" port="8008"></host>
   <debug start="false"></debug>
   <filesystem xfs="false"></filesystem>
   <filter start="false">
       <exclude expression="(.*)\.svn"></exclude>
       <exclude expression="(.*)\.gz"></exclude>
       <exclude expression="^temp/*"></exclude>
       <exclude expression="^cache/*"></exclude>
   </filter>
   <inotify>
       <delete start="true"></delete>
       <createfolder start="true"></createfolder>
       <createfile start="true"></createfile>
       <closewrite start="true"></closewrite>
       <movefrom start="true"></movefrom>
       <moveto start="true"></moveto>
       <attrib start="true"></attrib>
       <modify start="true"></modify>
   </inotify>
   <sersync>
       <localpath watch="/var/local/data">
           <remote ip="192.168.1.20" name="data_sync"></remote>
       </localpath>
       <rsync>
           <commonparams params="-auvzP"></commonparams>
           <auth passwordfile="/etc/rsync.secrets" start="true" users="syncuser"></auth>
           <userdefinedport port="873" start="false"></userdefinedport>
           <timeout start="true" time="100"></timeout>
           <ssh start="false"></ssh>
       </rsync>
       <faillog path="/usr/local/sersync/log/rsync_fail_log.sh" timetoexecute="60"></faillog>
       <crontab schedule="600" start="false">
           <crontabfilter start="false">
               <exclude expression="*.php"></exclude>
               <exclude expression="temp/*"></exclude>
           </crontabfilter>
       </crontab>
       <plugin name="command" start="false"></plugin>
   </sersync>


Key configuration elements:

  • localpath: Directory to monitor for changes on the source server
  • remote ip: IP address of the destination server
  • name: Rsync module name defined on the destination server
  • commonParams: Rsync command parametres

4. Create Source Directory

[root@src-server ~]# mkdir -p /var/local/data

5. Set Environment Variables

[root@src-server ~]# echo "export PATH=$PATH:/usr/local/sersync/bin/" >> /etc/profile
[root@src-server ~]# source /etc/profile

6. Start Sersync

[root@src-server ~]# sersync2 -r -d -o /usr/local/sersync/conf/confxml.xml

To restart Sersync:

[root@src-server ~]# killall sersync2 && sersync2 -r -d -o /usr/local/sersync/conf/confxml.xml

7. Configure System Startup

[root@src-server ~]# echo "sersync2 -r -d -o /usr/local/sersync/conf/confxml.xml" >> /etc/rc.d/rc.local

Testing the Configuration

On the Source Server

[root@src-server ~]# ls /var/local/data/
[root@src-server ~]# touch testfile.txt
[root@src-server ~]# ls /var/local/data/
testfile.txt

On the Destination Server

[root@dest-server ~]# ls /var/backups/sync_data/
[root@dest-server ~]# ls /var/backups/sync_data/
testfile.txt

The file should appear on the destination server shortly after being created on the source server, demonstrating that the synchronization is working correctly.

Troubleshooting Tips

  • Verify firewall rules allow Rsync traffic (default port 873)
  • Check SELinux settings if synchronization fails
  • Review log files at /var/log/rsyncd.log and /usr/local/sersync/log/
  • Ensure proper file permissions on both source and destination directories
  • Verify network connectivity between the servers

Tags: sersync rsync file-synchronization centos linux-administration

Posted on Sun, 12 Jul 2026 17:18:03 +0000 by Ravenous