yum install -y rsync xinetd
mkdir rsyncd # Create a folder for storing configuration files in a centralized management.
touch /etc/rsyncd.conf # Create rsyncd.conf This is the rsync server's configuration file.
touch /etc/rsyncd/rsyncd.secrets #Create rsyncd.secrets This is the user password file.
chmod 600 /etc/rsyncd/rsyncd.secrets # Will rsyncd.secrets the password file file attributes set to root and the authority to set to 600 or else can not be successful backup.
touch /etc/rsyncd/rsyncd.motd # Define rsync server information.
#port = 873 # Specify the operating port default is 873 can also specify their own, do not set, use the '#' comment out. uid = root # Server-side transmission of documents to which users to implement the default is nobody, but nobody may encounter permission problems Some documents from the server pull down This article users use root. gid = root # Ibid to set the server-side transmission of documents to which group to implement. use chroot = no # Whether to use chroot, the advantage is likely to protect the system from being exploited by the vulnerability. The disadvantage is that superuser privileges are required, and the symbolic link file will be excluded. read only = yes # Read only mode does not allow the client to upload files to the server, the other there is a write only option. hosts allow=192.168.1.0/24 # Allow the host, you can specify a single IP can also specify the entire network segment can improve security, multiple address formats to use spaces separated. #hosts deny=* # Specify not allowed to connect rsync server machine, you can use the scope of the definition of hosts allow to define the default is no hosts deny definition can be used '#' comment out. max connections = 5 # The maximum number of connections to the client. pid file = /var/run/rsyncd.pid # Tell the process to write to the /var/run/rsyncd.pid file. secrets file = /etc/rsyncd/rsyncd.secrets # Specify the password file path. log file = /var/log/rsyncd.log # Open the rsync server log. lock file = /tmp/rsync.lock # Specifies the lock file that supports the max connections parameter. #motd file = /etc/rsyncd/rsyncd.motd # Specify the definition of the server information file path, when the user login will see this information, non must be used '#' comment out. transfer logging = yes # So that the rsync server record the download and upload operations in their own separate log. log format = %t %a %m %f %b # This option allows you to customize the log file by using transfer logging. The format is a string containing the format identifier,% t current time,% a remote IP address,% m module name,% f file name,% B The actual number of bytes transmitted, the detailed settings can be self study. syslog facility = local3 # Specifies that rsync sends a log message to syslog. The common message levels are: uth, authpriv, cron, daemon, ftp, kern, lpr, mail, news, local0, local1, local2, local3, local4, local5, local6, Local7 and other default value is daemon. timeout = 300 # This option allows you to override the customer specified IP timeout. With this option, you can ensure that the rsync server does not wait for a crashing client forever. The timeout unit is in seconds 0 indicates no timeout definition This is also the default value. [monitor] # Module it provides us with a link name, in this module is linked to the /var/spool/asterisk/monitor directory to use [name] form. path = /var/spool/asterisk/monitor # Specify the location of the file directory which is required to be specified. list=no # This means that the directory on the rsync server that provides the synchronization data is listed on the server. The default is yes. If you do not want to list it, set it to no. ignore errors # Ignore IO errors. auth users = test # Certified users. comment = Get monitor # Annotation information can be defined by yourself. #exclude = data/ cache/ # Exclude the meaning of the monitor directory under the data and cache excluded, there are spaces between the directory, there is no comment can be used ’#‘.
Disable set to no, flags set to IPv4, server set to rsync path can be used whereis rsync view, and then execute “service xinetd restart” to make the above settings take effect.
Set the password file format is very simple, rsyncd.secrets content format: user name: password format, the following example:
test:astercc
/usr/bin/rsync --daemon
echo "astercc" > /root/rsyncd.secrets chmod 600 /root/rsyncd.secrets
rsync -avzP test@192.168.1.90::monitor /var/spool/asterisk/monitor --password-file=/root/rsyncd.secrets
rsync -avzP test@192.168.1.90::monitor /var/spool/asterisk/monitor --password-file=/root/rsyncd.secrets
-a To archive mode operation, copy the directory, symbolic link is equivalent to "-rlptgoD" -z Compression when transmitting. -P Transmission progress. -v Print the progress of information, and-P a little relationship, try their own. You can see the document. --delete Is that if the server to delete the file, then the client also delete the file accordingly, to maintain a true consistency, this case only for recording file backup so do not need this option. --password-file=/password/path/file To specify the password file, so that you can use in the script without the need to enter the interactive authentication password, and here need to pay attention to is the password file permissions is 600.