在整理手上幾臺SQL SERVER 2000的數據庫備份時,一方面為了方便快速還原數據庫,另外一方面為了備份冗余、備份方式統一(先備份到本地,然后收上磁帶),將以前通過Symantec Backup Exec直接備份上帶的作業改成了如下方式:
    Step 1: 通過數據庫維護計劃將備份生成在本地磁盤M,完整備份保留2天,事務日志備份保留3天
            M:/DB_BACKUP/FULL_BACKUP
            M:/DB_BACKUP/LOG_BACKUP
    Step 2:  備份完成后通過Symantec Backup Exec將備份文件收上磁帶。
但是發現即使SQL SERVER 2000的數據庫維護計劃設置了刪除幾天前的備份文件,但是發現根本沒有刪除過期備份。于是只好使用dos命令來處理。剛開始想用forfiles命令,結果我搜索的時候,發現Windows 2000下沒有forfiles命令,后來通過從第三方復制過來,發現Windows 2000下也可以使用forfiles(如果不借助于forfiles命令,直接用批處理命令完成這個,那簡直痛苦死了)
關于forfiles命令的語法如下所示
 
C:/>forfiles /?
FORFILES [/P pathname] [/M searchmask] [/S]
         [/C command] [/D [+ | -] {yyyy-MM-dd | dd}]
Description:
    Selects a file (or set of files) and executes a
    command on that file. This is helpful for batch jobs.
Parameter List:
    /P    pathname      Indicates the path to start searching.
                        The default folder is the current working
                        directory (.).
    /M    searchmask    Searches files according to a searchmask.
                        The default searchmask is '*' .
    /S                  Instructs forfiles to recurse into
                        subdirectories. Like "DIR /S".
    /C    command       Indicates the command to execute for each file.
                        Command strings should be wrapped in double            
新聞熱點
疑難解答