Last-modified: 2013-03-16 (土) 22:31:14
スクリプト/backup.bat

概要

Macrium Reflect Free Editionを使った定期バックアップ用のバッチです。

コード

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
:: 
:: ローテートするイメージバックアップ
:: 
 
::@echo off
 
:: =============================================================================
 
::バックアップ先パス
@set BACKUP_CURRENT=Z:\hoge\
:: ローテートする回数(4週x3回=12)
@set MAX_ROTATE=12
:: Reflect
@set REFLECT="C:\Program Files\Macrium\Reflect\reflect.exe"
:: devcon
@set DEVCON="C:\Windows\devcon.exe"
 
:: =============================================================================
 
:: ローテート
@rmdir /s /q %BACKUP_CURRENT%%MAX_ROTATE% 2>nul
@set BACKUP_PATH=%BACKUP_CURRENT%
@set COUNT=%MAX_ROTATE%
:loop
    @set /a TEMP=COUNT-1
    @ren %BACKUP_CURRENT%%TEMP% %COUNT% 2>nul
    @set /a COUNT=COUNT-1
    @if not %TEMP% == 1 goto loop
    
:: バックアップ用フォルダ作成
@mkdir %BACKUP_PATH%1 2>nul
 
:: バックアップ
:: System(C:)
%REFLECT% -e -w "C:\Documents and Settings\paburica\My Documents\Reflect\backup_system.xml"
:: (D:)
%REFLECT% -e -w "C:\Documents and Settings\paburica\My Documents\Reflect\backup_d.xml"
:: Alice(F:)
%REFLECT% -e -w "C:\Documents and Settings\paburica\My Documents\Reflect\backup_alice.xml"
:: Aika(G:)
%REFLECT% -e -w "C:\Documents and Settings\paburica\My Documents\Reflect\backup_aika.xml"
 
:: バックアップ用ドライブアンマウント
%DEVCON% disable "USBSTOR\DiskI-O_DATAHDCS-U______________"
%DEVCON% disable "USB\Vid_04bb&Pid_0121&Rev_0000"

検証時の環境