zoukankan      html  css  js  c++  java
  • delete_old_backup.bat

      在前面forfiles命令批量删除N天前文件 这篇文章里面讲述了如何在SQL Server 2000中使用forfile删除N天前备份文件,但是现在又有新需求:

      需求描述:通过数据库维护计划将备份生成在本地磁盘M(M盘位于单独的SAN存储,该SAN存储专门用于保留备份),完整备份保留2天,事务日志备份保留2天,但是M:DB_BACKUPFULL_BACKUP目录下只能保留最新的一份完整备份,旧的备份必须移动到M:DB_BACKUPOLD_BACKUP,这样我就可以通过Symantec Backup Exec只将FULL_BAKCUP和LOG_BACKUP目录收上磁带。否则通过Symantec Backup Exec将备份收上磁带时,将出现冗余。一来需要消耗更多的磁带,最麻烦的是因为SAN存储和磁带机位于不同地域的机房,虽然通过1G的光纤连接,但是由于我们磁带机只有两个Drive,只能并行跑两个作业,所以必须减少冗余,防止作业被滞留到白天,影响网络带宽,所以必须修改手头几台SQL Server 2000的备份策略,修改delete_old_backup.bat命令

                M:DB_BACKUPFULL_BACKUP

                M:DB_BACKUPLOG_BACKUP

                M:DB_BACKUPLOG_BACKUP

    image

     

     

    delete_old_backup.bat 脚本如下所示:

    echo  --**************************************************************-- >>delete_old_backup.log
     
    echo  --Delete the backup log start at %Date% - %time% -->>delete_old_backup.log
     
    rem Keep the backup log days definition.
     
    set LogKeepDays=2
     
    rem delete the old backup log files LogKeepDays ago.
     
    set LogPath=M:DB_BACKUP
     
    forfiles -p%LogPath% -m*.txt -d-%LogKeepDays% -c"cmd /c del /q @FILE" >> delete_old_backup.log
     
    echo Delete the backup log End at %Date% - %time% >>delete_old_backup.log
     
     
     
    echo --Delete the folder old_bakcup full backup start at %Date% - %time% -- >>delete_old_backup.log
     
    set OldBackupPath=M:DB_BACKUPOLD_BACKUP
     
    set OldBkKeepDays=1
     
    forfiles -p%OldBackupPath% -m*.bak -d-%OldBkKeepDays% -c"cmd /c del /q @FILE" >> delete_old_backup.log
     
    echo --Delete the folder old_bakcup full backup end at %Date% - %time% -->>delete_old_backup.log
     
     
     
    echo Move the full backup start at %Date% - %time% >>delete_old_backup.log
     
    set FullBkKeepDays=1
     
    set FullBackupPath=M:DB_BACKUPFULL_BACKUP
     
    forfiles -p%FullBackupPath% -m*.bak -d-%FullBkKeepDays% -c"cmd /c move @FILE M:DB_BACKUPOLD_BACKUP" >> delete_old_backup.log
     
    echo Move the full backup End at %Date% - %time% >>delete_old_backup.log
     
     
    echo Delete the log backup start at %Date% - %time% >>delete_old_backup.log
     
    set LogBackupPath=M:DB_BACKUPLOG_BACKUP
     
    set LogBkKeepDays=2
     
    forfiles -p%LogBackupPath% -m*.TRN -d-%LogBkKeepDays% -c"cmd /c del /q @FILE" >> delete_old_backup.log
     
     
    echo Delete the log backup Stop at %Date% - %time% >>delete_old_backup.log
     
    echo  --****************************************-- >>delete_old_backup.log
  • 相关阅读:
    C++ 多线程编程
    协程简介(coroutine)
    Yanhua Digimaster 3如何使用免焊适配器重置仪表板?
    Autel OTOFIX IM1 远程/在线技术支持指南
    Xhorse奥迪免焊适配器套装功能列表+常见问题
    如何通过 DDD 构建一辆汽车
    周末复习一波Linux,Linux常用命令总结,还有语法+案例
    Dubbo 基础知识
    GIT版本控制学习博客
    C++检测和定位内存泄漏
  • 原文地址:https://www.cnblogs.com/kerrycode/p/4203468.html
Copyright © 2011-2022 走看看