- Create a shell script
The content of the creation script is as follows:
/usr/bin/mysqldump -u$db_user -p$db_passwd $db_name >>/data/backup/$name.sql
/usr/bin/mysqldump: //The path of the mysqldump backup tool in the mysql database installation directory
demodb: // The name of the database to be backed up
/data/backup/$name.sql: //The output location of the backup file can be set according to the situation
- Add execute permission to shell script
chmod +x dbbackup.sh
- Add a scheduled task to the script
Enter the name of the previous line to edit the scheduled task, and finally add the following content
00 01 * * * /bin/sh /usr/local/mysql/dbbackup.sh
At 1 am every day, an automatic backup script will be executed to perform regular backups of the MySQL database.
restart task process
service cron restart
Description of the crontab file:
In the crontab file created by the user, each line represents a scheduled task, and each field in each line represents a setting. Its format is divided into six fields per line. The first five paragraphs are time setting fields, and the sixth paragraph is the time setting field. segment is the command field to execute.
The format is as follows:
minute hour day month week command
minute: Indicates the minute, which can be any integer from 0 to 59.
hour: Indicates the hour, which can be any integer from 0 to 23.
day: Indicates the date, which can be any integer from 1 to 31.
month: Indicates the month, which can be any integer from 1 to 12.
week: Indicates the day of the week, which can be any integer from 0 to 7, where 0 or 7 represents Sunday.
command: The command to be executed, which can be a Linux system command or a script program written by yourself.
- MySQL remote connection configuration method under docker container
- MySQL database storage path change
- mysql database connection failed | SQLSTATE[HY000]  Connection refused solution
- Personal blog database selection, mysql vs sqlite?
- mysql数据库链接失败| SQLSTATE[HY000]  Connection refused 解決方法
- chevereto 50%优惠限时促销
- Super simple, method for registering program or software as system service under windows system
- 收藏：MySQL 數值型函數大全
- 个人博客数据库选择，mysql vs sqlite?