回覆回應

ExpressMaint

 

Usage:

expressmaint -S (local)\SQLExpress -D ALL_USER -T DB -R c:\reports  -RU WEEKS -RV 1 -B c:\backups -BU DAYS -BV 1 -V

 

-U      SQL Authentication Login. If not specified a trusted windows connection is used.
-P      SQL Authentication Password

-S        connect to
-D       database
-T <Type>
    DB - Full Database Backup
    LOG - Log Backup
    CHECKDB - Database Integrity Check
   
-R             reports are written to
-RU           unit(minutes, hours, days, weeks)
-RV             number of copies of old reports to keep.

-B               backups to
-BU             how long old backup files are kept.
-BV             The time period of old backups to keep.

-V                 Indicates whether to verify the backup file
-BF               $(DB_$(DATE)_$(TIME)_$(OPTYPE)

 


 

Example: backupdb.bat

 

REM backup mssql db

C:\mssql_backup\expressmaint.exe -S TEST -U sa -P testing -D TESTING -T DB -R C:\mssql_backup\log  -RU minutes -RV 3 ^
                                                         -B C:\mssql_backup\db -BU minutes -BV 3 -BF  $(DB)_$(DATE)_$(TIME)_$(OPTYPE) -V

C:\mssql_backup\expressmaint.exe -S TEST -U sa -P testing -D TESTING -T LOG -R C:\mssql_backup\log  -RU minutes -RV 3 ^
                                                          -B C:\mssql_backup\db -BU minutes -BV 3 -BF   $(DB)_$(DATE)_$(TIME)_$(OPTYPE) -V

 

Output:

 

TESTING_FullBackup_20120307_1225
TESTING_LogBackup_20120307_1225

 

P.S.

假設每 min backup 一次

min  20    21     22        X        X       25  <-- 在 25min 的 backup 會 Delete 22,21,22 分的 backup !!!!
        bu    bu     bu     miss   miss     bu

所以當幾次 backup 失敗後再 backup, 記得移開要保留的 Backup 先 !!

 


 

Example log:

 

Success:

Expressmaint utility v2.0.0.1 , Logged on to SQL Server [TEST] as [sa]
Created by Jasper Smith (www.sqldbatips.com)

Starting backup on 7/3/2012 12:30:47

[1] Database TESTING: Backup starting at 7/3/2012 12:30:47
    Database backed up to C:\mssql_backup\db\TESTING\TESTING_20120307_1230_FullBackup.bak
    Backup completed in 0 hour(s) 0 min(s) 0 second(s)

[2] Database TESTING: Verify starting at 7/3/2012 12:30:47
    Backup file C:\mssql_backup\db\TESTING\TESTING_20120307_1230_FullBackup.bak verified
    Verify backup completed in 0 hour(s) 0 min(s) 0 second(s)

[3] Database TESTING: Delete old backup files
    Deleted file C:\mssql_backup\db\TESTING\TESTING_20120307_1225_FullBackup.bak
    1 file(s) deleted.


[4] Delete old Report files...
    Deleted file C:\mssql_backup\log\TESTING_FullBackup_20120307_1225.txt
    1 file(s) deleted.



Expressmaint finished successfully at 7/3/2012 12:30:47 with Return Code(0)

 


Fail:

    Failed to connect to server TEST.
    Login failed for user 'sa'.


Expressmaint finished unsuccessfully at 7/3/2012 12:35:13 with Return Code(-3)

回應

此欄位內容將保密,不會公開顯示出來。