linux file system Rsync synchronization scheme

Under linux Rsync server configuration file synchronization


  1. Rsync (remote synchronize) remote data synchronization tool, you can use the "Rsync algorithm"
    file synchronization between the local and remote hosts, the benefits Rsync is only synchronize two different portions of files,
    the same part is not passed, similar to an incremental backup this makes the backup file transfer or synchronize files on the server.
  2. can be achieved with the use crontab rsync synchronization tasks scheduled backups.

Rsync deployment environment
1, the server is ready
| Host | IP | ---------- |
| Server | 192.168.60.110 | ---------- |
| Client | 192.168.60.80 | - -------- |

2、Server

        2.1、ubuntu  16.04默认已安装rsync,直接修改它的配置文件即可。
        sudo vim /etc/default/rsync
        RSYNC_ENABLE=true   #false改true

3, modify the configuration file
3.1, rsync wear in the default file in / usr / share / doc / rsync / examples / , it is necessary to manually configure the files are copied to the / etc directory,
the sudo CP / usr / Share / DOC / the rsync / examples /rsyncd.conf / etc
3.2, modify the configuration file conf.
sudo vim /etc/rsyncd.conf

            #motd file=/etc/motd
            log file=/var/log/rsyncd
            #for pid file, do not use /var/run/rsync.pid if
            #you are going to run rsync out of the init.d script.
            #The init.d script does its own pid file handling,
            #so omit the "pid file" line completely in that case.
            pid file=/var/run/rsyncd.pid
            syslog facility=daemon
            #socket options=
            #MODULE OPTIONS
            [ftp]
    comment = public archive
    path = /home/zy/ftp
    use chroot = no
            #max connections=10
    lock file = /var/lock/rsyncd
            #the default for read only is yes...
    read only = yes
    list = yes
    uid = nobody
    gid = nogroup
            #exclude = 
            #exclude from = 
            #include =
            #include from =
    auth users = liu_rsync
    secrets file = /etc/rsyncd.secrets
    strict modes = yes
    hosts allow = 192.168.60.110
            #hosts deny =
    ignore errors = no
    ignore nonreadable = yes
    transfer logging = no
            #log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
    timeout = 600
    refuse options = checksum dry-run
    dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz

4, create a password file
vim /etc/rsyncd.pwd
content: rsync: 123
sudo chmod 0600 /etc/rsyncd.pwd
5, start rsync
sudo /etc/init.d/rsync Start
If the startup is successful, the server end wine Configuring a success.

Client

1, the client does not require special configuration, direct synchronization to
rsync -vzrtopg --progress [email protected] :: my_rsync_bk.
1.1, only this time rsync Server will end the existing data synchronization down, if the new Server adding data can not sync down, it's a bit uncomfortable.
1.2, you need to create a password file (and server-side keys can also be done free of)
sudo vim /etc/rsync.pwd enter the password to be consistent 123 #
sudo chmod 0600 /etc/rsync.pwd
sudo chown ordinary users: ordinary users group /etc/rsync.pwd
1.3, automatically execute: input command line terminal: crontab -e Add the following,
/. 1 the rsync --password-File = -a / etc / rsync.pwd [email protected] :: my_rsync_bk / the Data / / 1 is one minute long time synchronization Server-side add a new file, within one minute automatically synchronized to the client. 1.5, delete the files need to be synchronized need to add the --delete parameter / 1 * rsync --password-File = -a / etc / rsync.pwd --delete [email protected] :: my_rsync_bk / the Data / rsync synchronization configuration




Case:

First, the synchronization file from the local to the remote server
the rsync -avz / Home / FTP [email protected] .8 : Home / FTP
Second, the remote file server to the local synchronization -e the crontab
the rsync -avz [email protected] .8 : home / ftp / home / ftp


My synchronization parameters:

Remote PC Sync to your local PC. Performed once every ten minutes

Guess you like

Origin blog.51cto.com/11353391/2483106