Recently, I wrote a tutorial to implement automatic and timed backup for MySQL in Linux for later reference. I would like to share it with you. If you have any questions, please try again.
The premise is set to 00:00 in the morning, so that the stored data is from yesterday.
Speak nonsense. Start
1. First, I created/home/user/mysql_autobackup.sh
Note: The content of mysql_autobackup.sh is as follows:
/Usr/bin/mysqldump-uroot-ppassword_card>/st_backup/stcard _ $ (date + % Y % m % d). SQL
/Usr/bin/mysqldump-uroot-ppassword sthy_card>/st_backup/sthycard _ $ (date + % Y % m % d). SQL
2. Then add permissions for the script
# Chmod + x/Home/user/mysql_autobackup.sh
3. Then add crontab. The command is as follows:
# Crontab-e (similar to the vi Mode)
Then write the text:
0 0 ***/Home/user/mysql_autobackup.sh (that is, execute the script after 00:00 every day)
About0 0 *** if you don't understand this, you can find du Niang (Baidu). All kinds of explanations are available.
Save and exit (what? No? Esc, colon, X, and press Enter). The following message is displayed: crontab: installing new crontab.
Crontab added successfully
To verify the correctness, # crontab-l is displayed:
[Root @ localhost ~] # Crontab-l
0 0 ***/home/user/mysql_autobackup.sh
Yes .. ..