Linux rsync sync settings
Rsync is a data mirroring backup tool that keeps data synchronized between two servers, and the most frequently used scenario is backing up the data.
The installation method is as follows:
Installation
Installing rsync under Ubuntu can be achieved by following these steps:
The code is as follows |
Copy Code |
$ sudo apt-get install rsync xinetd
|
Configuration
1. Edit/etc/default/rsync start rsync as daemon for using xinetd
The code is as follows |
Copy Code |
$ sudo vim/etc/default/rsync Rsync_enable=inetd
|
2. Create/etc/xinetd.d/rsync make rsync work through xinetd
The code is as follows |
Copy Code |
$ sudo Vim/etc/xinetd.d/rsync Service rsync { disable = no socket_type = Stream wait = no user = root server =/usr/bin/rsync server_args =--daemon log_on_failure + = USERID } |
3. Create/etc/rsyncd.conf configuration rsync to make it in.
The code is as follows |
Copy Code |
$ sudo vim/etc/rsyncd.conf Max connections = 2 Log file =/var/log/rsync.log Timeout = 300 [Share] Comment = Public Share Path =/home/share Read Only = no List = yes UID = nobody GID = Nogroup Auth users = user Secrets file =/etc/rsyncd.secrets |
4. Create/etc/rsyncd.secrets configuration username and password.
The code is as follows |
Copy Code |
$ sudo vim/etc/rsyncd.secrets User:password |
4.a
The code is as follows |
Copy Code |
$ sudo chmod 600/etc/rsyncd.secrets |
5. Start/Restart XINETD
The code is as follows |
Copy Code |
$ sudo/etc/init.d/xinetd Restart |
Test
Run the following command check to confirm that the rsync configuration was successful.
The code is as follows |
Copy Code |
$ sudo rsync user@192.168.0.1::share Password: Drwxr-xr-x 4096 2006/12/13 09:41:59. Drwxr-xr-x 4096 2006/11/23 18:00:03 folders |
if it doesn't work out, take a few notes:
The code is as follows |
Copy Code |
/etc/rsyncd.conf: Auth users = user |
The user at the back is authorized to access the module and needs to correspond to the/etc/rsyncd.secrets.
Remote sync:
The code is as follows |
Copy Code |
sudo rsync-arlhptgzqh--delete--delay-updates--progress fhp@serverip::share--password-file=/etc/rsync_password/ Media/server/server1/home /etc/rsync_password |
You just need to fill in the code.
Unfortunately, rsync synchronization does not automatically detect whether a directory has file updates or changes, and then synchronizes, and requires that we synchronize in the system's scheduled tasks.