----------------------------------------------------------------------------
---- This is andkylee's personal originality. Please repost it with respect to the author's Labor achievements;
---- The original output must be specified for reprinting.Location
:
Http://blog.csdn.net/andkylee
---- Keywords: ASE database backup Automatic Continuous backup delete old backup
----------------------------------------------------------------------------
We know the Backup Frequency Based on the business data of the production database, such as monthly, weekly, daily, and sometimes even hourly. To back up the Sybase Database, you must manually write the command. In this way, the next backup file may be overwritten. Different backup file names generated by the script during the next backup will not overwrite the previous backup file. In this way, multiple database backup files of the database can be automatically retained, which effectively guarantees the security of the database.
Copy the following script to notepad and save it as BAT. Add the task to windows,
========================================================== ========================================================== ================
Echo off
CLS
: By default, database backup for the last seven days is retained. You can change 7 to the number of consecutive days you want.
: Where D:/Sybase/data is the database backup address, you can specify it again
: The Master is the default backup database name, which can be changed to another user database name.
Set databak_path = D:/Sybase/Data
Set databasename = Master
Echo dt = Date ()-7> % Temp %/olddate. vbs
Echo S = right (Year (DT), 4) ^ & "-" ^ & right ("0" ^ & month (DT), 2) ^ & "-" ^ & right ("0" ^ & Day (DT), 2) >>% TEMP %/olddate. vbs
Echo wscript. Echo S> % Temp %/olddate. vbs
For/F % F in ('cscript/nologo % Temp %/olddate. vbs ') Do @ set delflag = % F
: Delete the database backup file seven days ago
If exist "% databak_path %/% databasename % _ % delflag %. Dump" Del "% databak_path %/% databasename % _ % delflag %. Dump"
Del % Temp %/olddate. vbs
If exist % Temp %/dump_db.txt (DEL % Temp %/dump_db.txt)
Echo dump database % databasename % to "% databak_path %/% databasename % _ % Date :~ 0, 10%. Dump "> % Temp %/dump_db.txt
Echo go> % Temp %/dump_db.txt
ISQL-USA-p-syour_servername <"% Temp %/dump_db.txt"> % databak_path %/dump_log.txt
Del "% Temp %/dump_db.txt"