Powerful rsync website automatic backup tool
Rsync is a data image backup tool in unix-like systems-remote sync. A Fast Incremental Backup Tool, Remote Sync, supports local replication or synchronization with other SSH and rsync hosts. Compared with traditional cp, scp, and tar backup methods, rsync has the advantages of high security, fast backup, and support for Incremental backup. rsync can meet the demand for data backup with low real-time performance, for example, regularly back up the data on the file server to the remote server, and regularly perform data mirroring on the local disk.
Environment
CentOS 5.8 (64) 192.168.23.130 (service)
Centos 5.8 (64) 192.168.23.131 (client)
Software
Rsync-3.1.1.tar.gz (http://rsync.samba.org /)
Installation Steps
1. Prerequisites
A. Disable selinux and firewall (in my personal habits, selinux and firewall must be disabled in whatever circumstances)
B. yum install-y make gcc
2. Install rsync (service, client)
A.tar-zxf rsync-3.1.1.tar.gz
B. cd rsync-3.1.1
C ../configure -- prefix =/usr/local/rsync
D. make
E. make install
3. Configure rsync
A. vim/etc/rsyncd. conf (service)
Uid = root
Gid = root
Use chroot = no
[Apps]
Auth users = root
Secrets file =/etc/rsyncd. passwd
Munge symlinks = no
Read only = no
Path =/data/test
B. vim/etc/rsyncd. passwd (service)
Root: 111111
C. vim/etc/rsync. passwd (client)
111111
4. Start rsync (service)
/Usr/local/rsync/bin/rsync -- daemon -- config =/etc/rsyncd. conf
5. Synchronize files (client)
/Usr/local/rsync/bin/rsync-vzrtopg -- progress -- delete rsync: // root@192.168.23.131/apps/tmp/-- password-file =/etc/rsync. pas (service-> client)
/Usr/local/rsync/bin/rsync-vzrtopg -- progress -- delete/tmp/rsync: // root@192.168.23.131/apps -- password-file =/etc/rsync. pas (client-> service)
6. Verify
Check whether synchronization files exist in the corresponding directory.
It will be run manually in the future, which is definitely not suitable for lazy people. Next we will introduce Inotify-tools to achieve real-time automatic synchronization. Inotify is a Linux feature that monitors file system operations, such as reading, writing, and creating. Inotify is responsive, easy to use, and much more efficient than the busy polling of cron tasks. Learn how to integrate inotify into your application and discover a group of command line tools that can be used to further automate system governance.
7. Install Inotify-tools
A. wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
B .tar-zxf inotify-tools-3.14.tar.gz
C. cd inotify-tools-3.14
D ../configure -- prefix =/usr/local/inotify
E. make
F. make install
8. Write shell scripts (rsync. sh)
#! /Bin/sh
# Local dir
Dstdir = "/tmp /"
# Sync user
Rsyncuser = "root"
# Sync password
Rsyncpassword = "/etc/rsync. pas"
# Remote ip
Remoteip = "192.168.23.131"
# Remote module
Module = "apps"
# Sync remote server module to local dir
For ip in $ remoteip
Do
/Usr/local/rsync/bin/rsync-vzrtopg -- progress -- delete $ rsyncuser @ $ ip: $ module $ dstdir -- password-file = $ rsyncpassword
Done
# Monitor local dir, then rsync remote server module
/Usr/local/inotify/bin/inotifywait-mrq -- timefmt '% d/% m/% y % H: % m' -- format' % T % w % f % e'-e close_write, modify, delete, create, attrib, move $ dstdir | while read file
Do
For ip in $ remoteip
Do
/Usr/local/rsync/bin/rsync-vzrtopg -- progress -- delete $ dstdir $ rsyncuser @ $ ip: $ module -- password-file = $ rsyncpassword
Echo "$ {file} was rsynced">/tmp/rsync. log 2> & 1
Done
Done
9. chmod 755 rsync. sh
10. Run the shell script and check whether the operation is successful in the corresponding directory.
11. Set auto-start upon startup
Echo "sh/usr/local/inotify/rsync. sh &">/etc/rc. d/rc. local
Rsync + inotify implement real-time synchronization and backup of Git data
Rsync for file backup Synchronization
Rsync synchronizes two servers
Remote synchronization of Rsync in CentOS 6.5
Use Rsync in Ubuntu Linux for data backup and Synchronization
Linux uses the Rsync client to synchronize directories with the server for backup
For more details, please continue to read the highlights on the next page: