Use MySQL mysqlhotcopy to implement automatic database backup. the sh script source code can be added to the cortab at every day. Back up and package the MYSQL database. Set the source code of the file # crontab-e 0 1 ***/usr/local/src/backmysql. sh running www.2cto.com backmysql. sh for the scheduled task. You can configure the backup directory. The directory where the database name mysqlhotcopy is located, and the backup before the last 30 days can be deleted to avoid insufficient disk space. Success -------------------------------------------------------------------------------------------------------------------------#! /Bin/bash # yum-y install perl-DBD-MySQL // if mysqlhotcopy can't be runing, install it backdir = "/usr/local/backup/" mysqlbindir = "/usr/local/mysql/bin/" backdatabase = "cms" keepdays = 30 $ {mysqlbindir} mysqlhotcopy $ {backdatabase }$ {backdir} tar zcvfP $ {backdir }$ {backdatabase }_db _ $ (date + "% Y % m % d" -- date = "-1 day" ).tar $ {backdir }$ {backdatabase} www.2cto.com rm-rf $ {backdir }$ {backdatabase} _ db _ $ (date +" % Y % m % d "-- date ="-$ {keepdays} day "author Naola2001