我有下面的批处理文件,每天备份一次,并保存7天。
@echo off
C:
CD\ProAuto
setlocal enableextensions
:: Get Numeric Date
for /F "skip=1 delims=" %%F in ('wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE') do ( for /F "tokens=1-3" %%L in ("%%F") do (
set CurDay=0%%L
set CurMonth=0%%M
set CurYear=%%N
))
set CurDay=%CurDay:~-2%
set CurMonth=%CurMonth:~-2%
:: Get numeric Day of the Week
for /f %%a in ('wmic path win32_localtime get dayofweek /format:list ^| findstr "="') do (set %%a)
:: Get Time and Date with full Month and Day of week
for /f "skip=8 tokens=2,3,4,5,6,7,8,9 delims=,: " %%D in ('robocopy /l * T: T: /ns /nc /ndl /nfl /np /njh /XF * /XD *') do (
set "dow=%%D"
set "month=%%E"
set "DD=%%F"
set "YYYY=%%G"
set "HH=%%H"
set "MM=%%I"
set "SS=%%J"
set "AMPM=%%K"
)
IF "%AMPM%"=="AM" ( Set AMPM=am )
IF "%AMPM%"=="PM" ( Set AMPM=pm )
Set RoboLog="C:\ProAuto\Logs\~%DayofWeek% %dow%.log"
Echo QuickBooks Backup %dow%, %month% %dd%, %yyyy% @ %hh%:%mm%:%ss%%AmPm% >%RoboLog%
:: The following checks to see if the database is locked by attempting to rename the file to the same name.
ren "C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\XYZ.QBW" "XYZ.QBW" >nul && (goto UnLocked) || (goto Locked)
Goto Donelocked
:UnLocked
echo QuickBooks is UnLocked and will be backed up >>%RoboLog%
Net Use "\\192.168.0.246\Backup Files"
Net Use "\\192.168.0.252\QB_BK"
Move "\\192.168.0.252\QB_BK\%DayofWeek% %dow%*" "\\192.168.0.252\QB_BK\%DayofWeek% %dow% %CurYear%-%CurMonth%-%CurDay%"
robocopy "C:\Users\Public\Documents\Intuit\QuickBooks\Company Files" "\\192.168.0.252\QB_BK\%DayofWeek% %dow% %CurYear%-%CurMonth%-%CurDay%" /XD "QuickBooksAutoDataRecovery" /MIR /FFT /V /NP /NDL /copy:DAT /dcopy:T /r:2 /W:2 /log+:%RoboLog% /tee
Call :RoboCheck
If %RoboRC% GTR 7 Goto QBBKFail
:QBBKGood
Echo QuickBooks Daily Backup Successful! >>%RoboLog%
goto doneQBBK
:QBBKFail
Echo QuickBooks Daily Backup Had Errors! >>%RoboLog%
Echo Sending Error Email with Log to Clients >> %RoboLog%
powershell -executionpolicy bypass -file %~dp0QB_KS_Fail.ps1
:DoneQBBK
Echo Copying Log to Backup Directory >>%RoboLog%
Copy %RoboLog% "\\192.168.0.252\QB_BK\" >>%RoboLog%
Goto Donelocked
:Locked
echo QuickBooks is Locked and cannot be backed up because it is open on a client computer >>%RoboLog%
echo Generating an Open File report and Emailing it to Clients
Set OpenFileLog="C:\ProAuto\Logs\QB_Open_Files %curmonth%-%curday%-%curyear%.log"
Echo Open QuickBooks Files >> %RoboLog%
Echo Open QuickBooks Files > %OpenFileLog%
Echo %dow%, %month% %dd%, %yyyy% @ %hh%:%mm%:%ss%%AmPm% >> %RoboLog%
Echo %dow%, %month% %dd%, %yyyy% @ %hh%:%mm%:%ss%%AmPm% >> %OpenFileLog%
openfiles /query /v | findstr /rc:"^$" /c:"Locally" /c:"remotely" /c:"----------" /c:"======" /c:"Accessed" /c:"QuickBooks" >> %RoboLog%
openfiles /query /v | findstr /rc:"^$" /c:"Locally" /c:"remotely" /c:"----------" /c:"======" /c:"Accessed" /c:"QuickBooks" >> %OpenFileLog%
Echo Sending Open Files Email to Clients >> %RoboLog%
powershell -executionpolicy bypass -file %~dp0Locked_Email.ps1
Del %OpenFileLog%
:DoneLocked
Goto :EOF
:RoboCheck
Set RoboRC=%ErrorLevel%
Echo Return Code: %RoboRC% >>%RoboLog%
if %RoboRC% EQU 16 echo ***FATAL ERROR*** >>%RoboLog% & echo Serious error. Robocopy did not copy any files. >>%RoboLog% & echo Either a usage error or an error due to insufficient access privileges >>%RoboLog% & echo on the source or destination directories. >>%RoboLog%
if %RoboRC% EQU 15 echo Code 15 = Code 1 OKCOPY + Code 2 XTRA + Code 4 MISMATCHES + Code 8 COPYFAIL: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. >>%RoboLog% & echo Examine the output log for details. >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 14 echo Code 14 = Code 2 XTRA + Code 4 MISMATCHES + Code 8 COPYFAIL: >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. No files were copied >>%RoboLog% & echo Examine the output log for details. >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 13 echo Code 13 = Code 1 OKCOPY + Code 4 - MISMATCHES + Code 8 COPYFAIL: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 12 echo Code 12 = Code 4 MISMATCHES + Code 8 COPYFAIL: >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 11 echo Code 11 = Code 1 OKCOPY + Code 2 - XTRA + Code 8 COPYFAIL: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 10 echo Code 10 = Code 2 XTRA + Code 8 COPYFAIL: >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. No files were copied >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 9 echo Code 9 = Code 1 OKCOPY + Code 8 - COPYFAIL: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 8 echo Code 8 COPYFAIL - Some files or directories could not be copied >>%RoboLog% & echo (copy errors occurred and the retry limit was exceeded). >>%RoboLog% & echo Can be caused by Open or Locked Files, Permission Issues, or Network Rescources Unavailable >>%RoboLog% & echo Check these errors further. >>%RoboLog%
if %RoboRC% EQU 7 echo Code 7 = Code 1 OKCOPY + Code 2 XTRA + Code 4 MISMATCHES: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. >>%RoboLog% & echo Examine the output log for details. >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog%
if %RoboRC% EQU 6 echo Code 6 = Code 2 XTRA + Code 4 MISMATCHES: >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. No files were copied >>%RoboLog% & echo Examine the output log for details. >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog%
if %RoboRC% EQU 5 echo Code 5 = Code 1 OKCOPY + Code 4 MISMATCHES: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog%
if %RoboRC% EQU 4 echo Code 4 MISMATCHES - Some Mismatched files or directories were detected. >>%RoboLog% & echo Examine the output log. Housekeeping might be required. >>%RoboLog% & echo Can be causes by different file systems reporting of timestapmps >>%RoboLog%
if %RoboRC% EQU 3 echo Code 3 = Code 1 OKCOPY + Code 2 XTRA: >>%RoboLog% & echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog% & echo Code 2 XTRA - Some Extra files or directories were detected. >>%RoboLog% & echo Examine the output log for details. >>%RoboLog%
if %RoboRC% EQU 2 echo Code 2 XTRA - Some Extra files or directories were detected. No files were copied >>%RoboLog% & echo Examine the output log for details. >>%RoboLog%
if %RoboRC% EQU 1 echo Code 1 OKCOPY - One or more files were copied successfully >>%RoboLog%
if %RoboRC% EQU 0 echo No errors occurred, and no copying was done. >>%RoboLog% & echo The source and destination directory trees are completely synchronized >>%RoboLog%
Goto :EOF
它的作用是每周一重命名周一备份目录以包含当前日期,然后使用Robocopy将当前数据镜像到新目录。然后星期二,它对星期二目录等执行相同的操作,因此每个备份保留7天。
我想修改它以进行每周备份并保留6周。我在想我会将目录名称更改为第1周到第6周,并按顺序回收目录,但现在我没有简单的方法来确定我在哪个星期,因为没有像我使用星期几进行日常备份那样每6周重复一次的日历事件。
因此,我正在寻找一些方法或建议,以确定哪个备份目录最接近6周前的备份目录,以便重新循环使用正确的备份目录。有可能在6周前没有备份,在这种情况下,它只会创建一个备份,就像日常备份一样,如果缺少星期三,它只会创建一个新的星期三备份。我也不想总是使用最旧的备份,例如,如果机器停机,它丢失了一个备份,我不想更改顺序,我想使用6周前的备份或创建一个新的备份。
我想找出一种方法来计算哪个%WeekofCycle%,以便使用以下代码:
Move "\\192.168.0.252\QB_BK\Week %WeekofCycle%*" "\\192.168.0.252\QB_BK\Week %WeekofCycle%* %dow% %CurYear%-%CurMonth%-%CurDay%"
robocopy "C:\Users\Public\Documents\Intuit\QuickBooks\Company Files" "\\192.168.0.252\QB_BK\Week %WeekofCycle%* %dow% %CurYear%-%CurMonth%-%CurDay%" /XD "QuickBooksAutoDataRecovery" /MIR /FFT /V /NP /NDL /copy:DAT /dcopy:T /r:2 /W:2 /log+:%RoboLog% /tee
我正在尝试找出一种方法来计算它在周期中的哪一周,而不管哪些备份可能已经完成或尚未完成,也不管是否有额外的备份或不存在的备份。如果我计算出我在第3周,我将重命名之前的备份为“\192.168.0.252\QB_BK\第3周*”,现在将日期和日期附加到它之后,然后使用带有Robocop的新名称来更新更改的文件。
我要做的是将每个目标目录命名为yyyymmdd
-根据需要附加日名/日期/其他数据,并将目标目录名附加到文件(backups.log
)
成功备份当前数据后,然后
for /f "skip=42,delims=" %%a in (`sort /r backups.log`) do (
ECHO rd /s /q "%%a"
findstr /v /x "%%a" backups.log >dummy.txt
move dummy.txt backups.log
)
这将按相反的日期顺序对备份目录的名称进行排序,以便最新的目录名位于第一位。跳过前42=6周*7天的行,并使用rd删除任何其他条目(最早的条目),然后从备份中删除。使用findstr记录文件,以输出那些与刚刚删除的目录不匹配的行,从而将保留的42个备份从文件和文件系统中删除。
请注意,的将处理读取备份的反向排序结果。记录文件。此结果保存在内存中,不受备份更改的影响。由
for循环生成的日志。
有没有纯注解为Spring留档?我看到的90%的文档都是为xml实现编写的。 我正在尝试覆盖默认的JobLauncher以能够传递JobParameters,但我添加到下面代码中的任何JobLauncher函数都被忽略,而是运行默认的SimpleJobLauncher。 我想用4个不同的作业参数启动同一作业的4个并发实例。这些参数应该告诉读取器从哪个目录读取。 我可以使用@Value注释为目录传递
在下图中,我想把分数作为绿色椭圆内的文本。但是,不管循环中的和函数的顺序如何,椭圆都会在文本上绘制。有人能提出原因吗?我的循环如下所示。
Windows现在有一个改进的库,可以在批处理脚本中使用,以处理连接到系统的设备。 这就是所谓的设备控制台 - 。 Windows驱动程序开发人员和测试人员可以使用来验证是否正确安装并配置了驱动程序,包括正确的INF文件,驱动程序堆栈,驱动程序文件和驱动程序包。 也可以在脚本中使用DevCon命令(启用,禁用,安装,启动,停止和继续)来测试驱动程序。 DevCon是一个在本地计算机和远程计算机上执
问题内容: 我正在开发一些基于Web服务的应用程序,并且对Apache CXF解组有疑问。在我们的项目中,我们使用CXF 2.4.1版本。 当某些SOAP请求不正确时(例如,某些字段是文本而不是数字),CXF会抛出标准的SOAPFaultException,并且SOAP响应将使用以下标准字段构建: 项目要求说,如果发生任何故障,系统需要以其他格式响应,例如: 所以问题是:如何以某种方式覆盖此错误处
问题内容: 我正在使用adityasatrio的批处理文件来备份本地MySQL数据库,并且希望仅保留30个最新的备份文件。在此示例中使用root:root。 现在,我对以下问题进行了很好的了解: 批处理文件以删除超过N天的文件 https://serverfault.com/questions/49614/delete-files-older-than-x- days 将7个最新文件保存在一个文件
前提: 脚本每n秒运行一次,这将创建定义文件到定义位置的备份。创建n个备份后,清除(删除)过期的备份。 问题: 我设法开始使用此版本来备份文件夹并删除较旧的verisons,但当我尝试使用特定文件时“找不到文件”。我已经为此抓耳挠腮了几个小时,我可能错过了一些小东西。例如,我不想简单地删除所有. xlsx文件,因为Target文件夹中可能会有多个不同的. xlsx文件。如果有3个较新版本可用,我只