In linux, mysql automatically backs up databases and automatically deletes temporary files bitsCN.com.
Mysql automatically backs up databases and deletes temporary files in linux
1. Automatically delete temporary files at every day
First, check the crontab task list: crontab-l and then create: crontab-e to add a row: 00 03 * ** rm-rf/www/cmstest/my120/public/scripts/jpgraph/* save and exit. Restart the service:/etc/rc. d/init. d/crond restart
2. automatic database backup at every day
The system crontab is used to regularly execute backup files and save the backup results by date to achieve the purpose of backup.
1. create the path to save the backup file/mysqldata
# Mkdir/mysqldata
2. create the/usr/sbin/bakmysql file.
Path for searching database files:/var/lib/mysql, or/usr/local/mysql/var: 1./usr/local/mysql/bin/mysql-u root-p enter the Database 2. input: show databases; 3. you can view all the databases, 4. find/-name db (the name of the database you want to search for): # vi/usr/sbin/bakmysql enter the following code: rq = 'date + % Y % m % d' tar zcvf/mysqldata/mysql1_rq.tar.gz/var/lib/mysql
3. Modify file attributes to make them executable.
# Chmod + x/usr/sbin/bakmysql New job: first, check the crontab task list: crontab-l and then create: crontab-e: add a row 00 04 ***/usr/sbin/bakmysql, which indicates that backup is performed every day at 24 o'clock.
4. restart crond.
#/Etc/rc. d/init. d/crond restart every day after that, you can see a similar file in/mysqldata: mysql20040619.tar.gz.
BitsCN.com