1. First, create a backup directory and backup script file. this is not much to mention. 2. back up and submit the file as follows :#! /Bin/bashnow =$ (date + & quot; % Y % m % d & quot ;) # obtain the current date days = 5bk_dr =/# path to the backup directory find $ bk_dr/backup file name-mtime + $ days-execrm-rf {}\; # Delete $ days
1. create a backup directory and a backup script file.
2. submit the backup file as follows:
#! /Bin/bash
Now = $ (date + "% Y % m % d") # get the current date
Days = 5
Bk_dr = // # path of the backup directory
Find $ bk_dr/backup file name-mtime + $ days-exec rm-rf {}\; # Delete the backup file of $ days
Mysqldump-u database account-p database password database to be backed up | gzip> $ bk_dr/exported file name $now. SQL .gz
Username = root
Chown-R $ username: $ username $ bk_dr # set the backup file owner
Scp $ bk_dr/exported file name $ now. SQL linux account @ server IP address to be backed up:/path
(Scp is used here. in order not to enter the password of the backup server every time, you need to set Machine trust or use ftp or other methods)
3. set ssh trust for two machines
Use the ssh-keygen-t rsa command to create a trust certificate
Ssh B @ B mkdir-p. ssh create a. ssh directory on the machine to be backed up to store certificates
Cat. ssh/id_rsa.pub | ssh B @ B 'cat>. ssh/authorized_keys copy the certificate to the created directory and change it to authorized_keys.
In this way, you can use the ssh command to test the ssh user @ IP
4. convert the backup file into an executable file
Chmod + x file path
5. create a task plan
Vi/etc/crontab
Add a line of Command: the location of the Command execution file required by the account for execution time *** user Command/(you can query crond for details) restart crontab/etc/rc. d/init. d/crond restart start run: chkconfig crond on restart service crond restart