In linux, back up the MySQL database and delete the Backup Data seven days ago.
#! /Bin/bash # backup database hz jshuabo sdhuaboname =$ (date + % Y % m % d) /alidata/server/mysql-5.1.73/bin/mysqldump-u root-p123456 hz>/root/sqlBackup/hz. $ name. SQL/alidata/server/mysql-5.1.73/bin/mysqldump-u root-p123456 jshuabo>/root/sqlBackup/jshuabo. $ name. SQL/alidata/server/mysql-5.1.73/bin/mysqldump-u root-p123456 sdhuabo>/root/sqlBackup/sdhuabo. $ name. SQL # Delete the backup file file_path = "/root/sqlBackup" # method a # rm-rf 'Find $ file_path '*. SQL '-mitime 7-print'> delete. log; # method bfind $ file_path-mtime + 7-type f | xargs rm-f # method c # rm-f 'Find $ file_path-mtime + 7-type F'
In linux, how does mysql regularly back up and Delete backup files from a specified database XX days ago?
You want to write a script for automatic backup. I wrote one last month. It has been used for nearly a month. Please give me a copy.
Mailbox?
Linux server automatically backs up mysql database scripts!
You're lucky. I just got this done. send you a copy. Automatically run in the Job scheduler under the window to add, if you need Linux, please h! Me ··
@ Echo off
Set sqlserver = "aboa" \ * aboa name of the database you want to back up
Set dn = 7 days ago, you can set it yourself
Echo.
Echo automatically creates a folder back on disk D
Echo.
If exist D: \ back (
Echo "a folder already exists"
) Else (
Md D: \ back create folder back
)
Cd/d "D: \ back"
Echo Wscript. echo dateadd ^ ("d",-% dn %, date ^)> rd. vbs
For/f "tokens = 1-3 delims =-" % a in ('cscript // nologo rd. vbs ') do (
Set yy = % a & set mm = 00% % B & set "dd = 00% % c ")
Set ymd = % yy %-% mm :~ -2%-% dd :~ -2% & del rd. vbs
Set n = 0
For/f "delims =" % I in ('dir/B/a-d *. SQL ') do (
If "% ~ Ti "lss" % ymd % 9 "(
Cls & echo/& echo deleting % I
Set/a n + = 1
Del "% I "))
Cls & echo/& echo check the deletion of the backup files 7 days ago. % n % files are deleted.
Echo _______________________________
Echo.
Echo today is % date %
Echo time is % time %
Echo _______________________________
Echo.
Echo MySQL Database Backup
Echo is backing up data. Please wait .....
Echo.
Echo _______________________________
Mysqldump -- port 3306-h localhost-u root-proot -- default-character-set = utf8-R % sqlserver %> d: \ back \ % date :~ 0, 4%-% date :~ 5, 2%-% date :~ . The name of the database backed up by SQL is the date of the current day.
Echo.
Pause... remaining full text>