简体   繁体   中英

How to create a MySql Job to create a database backup and a maintenace plan?

How can I create a MySql Job that runs daily to generate a database backup and stores in on the server?

Also How can I create a second Job that does a maintenance on the database to keep it running without problem?

Thanks

one possible way is run the following as daily cron.

mysqldump -u <db_user> -p <db_password> <db_name> -h <db_host_if_any> > /home/backups/backup_<timestamp>.sql

gzip it and store it(just a mechanism to reduce size)

gzip /home/backup/backup_<timestamp>.sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM