Shell scripts and automatic backup of data to the mobile mass storage Linux

Automatic backup of the database and the mobile copy of the data backed up to the previous day's storage.

Sources of demand because linux disk storage system layer is too small, more and more data over time after the database is automatically backed up, but also do not want to delete the old data. That solution is to mount the memory on the host linux system to a specified directory, and then use the script to backup the database file is automatically moved to the copy store. Specific method is as follows:

1 Write the backup database script

mysqldump -uroot -p (mysql password) zabbix> /root/mysql.bak/zabbix`date +% Y% m% d`.sql

2 . Copied automatically to write backup data file to a storage

find /root/mysql.bak/ -mtime 1 -exec 'mv' {} /cephfs/zbx_mysql/ \;

-mtime parameters can be modified two days, documents three days, five days, and so on until all files + number represents the number of days before a few days ago.

3 Develop crontab scheduled tasks

4 Check your tasks

  

Guess you like

Origin www.cnblogs.com/lbjstill/p/11497066.html
Recommended