Linux configures COSCMD to regularly backup the database to COS, and regularly backup the database to Tencent COS every day

Lao Yang two hundred and thirty-four zero

Linux Configuring the COSCMD for Scheduled Database Backup to COS

 git clone  https://github.com/tencentyun/coscmd.git cd coscmd python setup.py install Coscmd - h # Test installation succeeded

The scheduled backup task is backed up in a folder every day. The COS storage files are automatically deleted for the backups that have been backed up for more than 30 days, so that the storage space will not be consumed all the time.

Automatically back up the lyplugin.com database and upload compressed SQL files to COS storage, and check to delete backup files that have been backed up for more than 30 days.

 #!/ bin/bash source /etc/profile cd /home/cosbak SQLFile=lyplugin.com_`date +%Y%m%d_%s`.sql DEltime=`date +%Y%m%d%H%M%S -d "30 day ago"` mysqldump -uroot -p**** lyplugin.com > $SQLFile tar -czvf $SQLFile.tar.gz $SQLFile rm $SQLFile /usr/local/bin/coscmd upload $SQLFile.tar.gz /$SQLFile.tar.gz for filename in *.sql.tar.gz do LAST_MODIFY_TIMESTAMP=`stat -c %Y  $filename` formate_date=`date '+%Y%m%d%H%M%S' -d @$LAST_MODIFY_TIMESTAMP`     if [ $formate_date \< $DEltime ];     then         rm $filename         /usr/local/bin/coscmd delete -f /$filename     fi done


Refer to official documents: https://cloud.tencent.com/developer/article/1853408


Copy Full Text
Export Document
Reward the author
Linux Configuration COSCMD Scheduled Backup Database to COS, Daily Scheduled Backup Database to Tencent COS Storage. doc
Download and save this article for collection and printing
Export Document