Configuring rsync and inotify-tools for Real-time Backup on CentOS 7
This guide explains how to install and configure rsync and inotify-tools on CentOS 7 servers, set up authentication, create a daemon, write a monitoring script, and verify that file changes on the client are automatically synchronized to the backup directory on the server.
This document provides step‑by‑step instructions for setting up a real‑time backup solution using rsync and inotify-tools on CentOS 7.
1. Install rsync on the server – verify installation with rpm -qa rsync or install via yum install rsync. Create /etc/rsyncd.conf with appropriate parameters (uid, gid, ports, allowed hosts, etc.) and a password file /etc/rsyncd/rsync.password containing root:root@mzla2019. Secure the password file with chmod 600 /etc/rsyncd/rsync.password. Start the daemon using rsync --daemon and confirm it is listening with netstat -nltp | grep rsync.
2. Install rsync on the client – repeat the installation steps and create the same password file under /etc/rsyncd/ with matching credentials, then set chmod 600 rsync.password.
3. Install inotify-tools – download, extract, configure, compile and install:
wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz tar zxvf inotify-tools-3.14.tar.gz cd inotify-tools-3.14 ./configure --prefix=/usr/local/inotify make make install4. Create the monitoring script ( inotify.sh) on the server:
#!/bin/bash host=192.168.1.1 src=/server/backup/ des=inotify password=/etc/rsyncd/rsync.password user=root inotify=/usr/local/inotify ${inotify}/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src \ | while read files; do rsync -avzP --delete --timeout=100 --password-file=${password} $src $user@$host::${des} echo "${files} was rsynced" >>/tmp/rsync.log 2>&1 doneMake the script executable with chmod 764 inotify.sh and run it in the background ( sh inotify.sh &). Add it to /etc/rc.local for persistence.
5. Test the setup – on the client create test files ( touch {1..10}.txt) and verify they appear in the server’s /server/backup/ directory.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
