Rsync + inotify for real-time server backup
Inotify:
Inotify is integrated into the kernel. inotify is used as a third-party software to monitor directory changes through the interfaces provided by the kernel.
The inotifywait command can monitor fine-grained real-time changes to files in the directory. The monitored command is
Inotifywait-mrq -- timefmt '% d/% m/% y % H: % m' -- format' % T % w % f % e'-e modify, delete, create, attrib/var/web
Execute this command, and the listening will always be run on the command interface. When the directory changes, the command will output the changed content. Then, use rsync to synchronize directories.
Rsync uses two working modes for synchronization, one is based on the ssh service for synchronization, use method: rsync [option] src user @ host: dir
The second method is rsync Socket mode. Use the rsync service to synchronize rsync [option] src rsync: // user @ host/web.
Inotify + rsync monitors local data changes. The server is installed on the machine to be synchronized.