Purpose: Copy files on a server (192.168.0.23) to B Server (192.168.0.25) on a daily basis and do not replicate if they already exist.
Ideas:
First, the server time is unified to avoid any inexplicable errors or management confusion. With NTP
Due to cross-server replication, the issue of automatic password entry is involved. Need to be addressed.
Using SCP replication will overwrite existing files and add useless work. Use Rsync instead.
Crontab is required for automatic execution of commands on a timed basis.
Steps to resolve:
Resolve time synchronization issues
Synchronize the time of the internal NTP server with the Ntpdate 192.168.0.253. In order to synchronize the time of the automatic execution later, in/etc/ntp.conf, add the NTP server:
Vi/etc/ntp.conf
Server 192.168.0.253
: X
Solve the problem of automatic password entry
Reference URL: http://blog.sina.com.cn/s/blog_8ad7d4ca01014lft.htm
There are two ways, one is to use expect, need to install. One is to use the key file. The second key file is used here.
Execute the following command on a server to generate the pairing key:
SSH-KEYGEN-T RSA
When prompted to enter the default, the public key is stored in the user directory. SSH directory, such as root:/root/.ssh/id_rsa.pub
Copy the Id_rsa.pub file from the. SSH directory to the ~/.ssh/directory of B and rename it to Authorized_keys.
Copy with rsync:
-avzu/root/.ssh/id_rsa 192.168.0.25:/backup/ncbackup
Write this command in the cron service:
Crontab-e
XX * * * */usr/bin/rsync-avzu/root/.ssh/id_rsa 192.168.0.25:/backup/ncbackup
Reference: http://www.blogjava.net/decode360/archive/2009/09/18/287743.html
Linux scheduled automatic offsite backup