The first type of wget direct download: Run the CRONTAB-E command on the remote server to add a timed task
7 * * * * cd/home/backup/&&wget http://Source server ip/xxx_$ (date +%y%m%d). tar.gz
(Automatically download to backup directory at 7:30 every day)
Using the SCP command backup requires that you first set up the SSH key login
Suppose that there are two Linux servers A and B, when a connection B does not need to enter a password, the implementation of a VPS on the use of the Ssh-keygen command to generate a pair of public key, the specific operation is as follows:
In a server operation:
Running: ssh-keygen-t RSA three times enter
Generates public key id_rsa.pub and private key Id_rsa, which are stored by default in the/root/.ssh/directory
Operating on the B server:
Upload a public key id_rsa.pub copy to the B server/root/.ssh/directory
PS: No. The SSH directory can be placed in another directory or create one: mkdir. SSH
Create one more: Touch/root/.ssh/authorized_keys
chmod 700/root/.ssh
Continue to operate on the B server:
Run:
Cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600/root/.ssh/authorized_keys
Reboot SSH after setting
CentOS Restart Ssh:service sshd restart
Debian reboot Ssh:service ssh restart
CentOS execution on a server: SSH root@b server ip-p port
Debian execution: ssh-l root b server Ip-p 22
See if you can login with a different password direct key. Exit Command: Exit
Second SCP commandThe specified directory to upload to the backup server on a local timer
Run the CRONTAB-E command on the local VPS to add timed tasks
7 * * * scp-p 22/home/www/zxsdw_$ (date + ' \%y\%m\%d ') tar.gz root@ remote server
(-P 22 refers to the port on which the backup server SSH is open and can be set itself.) Data in the local WWW directory is backed up to the back directory of the remote server
7 * * * * scp-p 22-r/home/www/zxsdw root@ remote server ip:/home/back/
(Zxsdw This folder to the back directory of the remote server)
Third Kind of SCP commandTimed downloads to the specified directory of the server
Run the CRONTAB-E command on a remote VPS to add a timed task
0 7 * * * * scp-p root@ data is located on the VPS ip:/home/www/zxsdw_$ (date + ' \%y\%m\%d '). tar.gz/home/back/
(Download the data from the source server www to the back directory of the backup server)
Because the WGET,SSH,SCP command supports backing up to a remote server, a single command can be executed.