rem -----------------------------------------------------
rem CドライブのシステムバックアップをDドライブに保存する
rem バックアップ中のエラーに備え、3世代の履歴を管理
rem -----------------------------------------------------
set BACKUP_LOG_FILE=e:\systembackup.log
rmdir /S /Q e:\WindowsImageBackup_2
move e:\WindowsImageBackup_1 e:\WindowsImageBackup_2
move e:\WindowsImageBackup e:\WindowsImageBackup_1
wbadmin START BACKUP -include:C: -backupTarget:e: -allCritical -quiet
echo %errorlevel%
rem wbadmin get status >> %BACKUP_LOG_FILE%
cscript //nologo status.vbs
echo %errorlevel%
2015年10月30日金曜日
status.vbs
'wbadmin 状況確認&自動復元&メール送信スクリプト
' 2010/10/24 by kenrouse
'------------------------------------------------
bRet = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set tso = fso.CreateTextFile("status.txt", true)
' 直前に実行されたバックアップの終了を待つコマンドです。
command = "wbadmin.exe get status"
' コマンドを実行します。
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(command)
' コマンドの出力結果を読み取ります。※ただし、進捗表示の出力は除去
Do While oExec.StdOut.AtEndOfStream <> True
strline = oExec.StdOut.ReadLine
If InStr(strline, "%") = 0 Then
tso.WriteLine strline
End If
'If InStr(strline, "バックアップ操作が正常に完了") = 1 Then
If InStr(strline, "エラー") = 1 Then
bRet = 1
End If
Loop
WScript.Sleep 1000
tso.Close
Wscript.Quit bRet
' 2010/10/24 by kenrouse
'------------------------------------------------
bRet = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set tso = fso.CreateTextFile("status.txt", true)
' 直前に実行されたバックアップの終了を待つコマンドです。
command = "wbadmin.exe get status"
' コマンドを実行します。
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(command)
' コマンドの出力結果を読み取ります。※ただし、進捗表示の出力は除去
Do While oExec.StdOut.AtEndOfStream <> True
strline = oExec.StdOut.ReadLine
If InStr(strline, "%") = 0 Then
tso.WriteLine strline
End If
'If InStr(strline, "バックアップ操作が正常に完了") = 1 Then
If InStr(strline, "エラー") = 1 Then
bRet = 1
End If
Loop
WScript.Sleep 1000
tso.Close
Wscript.Quit bRet
2015年10月19日月曜日
eo
robocopy "e:\test\in" "e:\test\backup" /MIR /LOG:"e:\test\log\log.txt" /TEE /V /X /FP /L /COPY:DATS /MT:8 /R:0
rem 容量があること
rem ファイルがクローズされている
rem BacpUpは共有されている
rem Backupフォルダに、ファイル書き込み中が判断できないか
setlocal
@echo off
echo %date% %time% start
set BacpUp=BacpUp
set BacpUp-1=BacpUp-1
set tmp=tmp
IF NOT EXIST %BacpUp% (
echo %BacpUp% %ERRORLEVEL%
exit /b 1
)
IF NOT EXIST %BacpUp-1% (
echo %BacpUp-1% %ERRORLEVEL%
exit /b 1
)
pushd E:\test
rem pause
ren %BacpUp-1% %tmp%
echo %ERRORLEVEL% ren %BacpUp-1% %tmp%
ren %BacpUp% %BacpUp-1%
echo %ERRORLEVEL% ren %BacpUp% %BacpUp-1%
ren %tmp% %BacpUp%
echo %ERRORLEVEL% ren %tmp% %BacpUp%
echo %date% %time% end
endlocal
rem pause
exit /b 0
登録:
投稿 (Atom)