1.Linux server is generally SSH protocol, if the local is also a Linux environment, you can directly through the shell Connection, command:
Ssh-l root-p 8080 202.***.***.***
Where Root is the user name, generally root,8080 for the port, 202.***.***.*** for the server IP address;
Next will prompt you to enter the password, the input is correct then enters the server;
2. Then you need to create a folder where database backup data is stored;
Mkdir/mysql/mysqldata_bakeup
/mysql/mysqldata_bakeup for the path created, can be customized;
3. Create and edit files in the path/usr/sbin/bakmysql, command:
Vi/usr/sbin/bakmysql
At this point, the Bakmysql file is created under the/usr/sbin/path and entered Bakmysql edit state, then input;
fn = ' Date +%y%m%d '
Tar Zcvf/mysql/mysqldata_bakeup/mysql$fn.tar.gz/mysql/data
Or
Mysqldump-u root-ppassword/mysql/data/yourdatabase >/mysql/mysqldata_bakeup/mysql$fn.sql
Find $fn-name "mysql*.tar.gz"-type f-mtime +7-exec fm{}; >/dev/null 2>&1
Or
Find $fn-name "Mysql*.sql"-type f-mtime +7-exec fm{}; >/dev/null 2>&1
/mysql/mysqldata_bakeup/saves the path for the backup data, msql$fn.tar.gz the name of the backup data according to the date number,/mysql/data the data path for the server database, yourdatabase the name of the database you want to back up;
Note that the first command is not a single quotation mark, but a symbol above the TAB key, and a space is required before and after date;
The second command has two methods, the first direct backup and compressed database data source files, the second is to use MySQL with the command mysqldump export database yourdatabase SQL files;
The third sentence is to delete the backup file 7 days ago, the filename is written corresponding to the second sentence.
4. Modify the file Bakmysql property to make it executable;
chmod +x/usr/sbin/bakmysql
5. Modify/etc/crontab:
Vi/etc/crontab
Go to edit state and add at the bottom:
3 * * * root/usr/sbin/bakmysql
01 3 is executed every 3:01 bakmysql documents;
6. Regarding the reboot sometimes does not need, if the server has the Crond service under the/etc/rc.d/init.d/path, may choose to reboot the Crond, the command:
/etc/rc.d/init.d/crond restart
7. Last Exit Server command: Exit
Summary:This article is based on the client local is also a Linux environment case, if the local is a Windows environment, you can install a client to remotely manage Linux, and then the procedures are basically the same, I hope this article will help you.