Thursday, September 29, 2011
Snapshot - command line options
Well - having a nice Windows interface is a fine thing - unless you want to automate certain things, which often is sheer impossible with all this Windows wizardry, often requiring dozens of clicks to accomplish even trivial tasks - just try to automate a Backup of your data with your favourite CD-ROM burning program.
Drive Snapshot has a very easy command line interface:
Backup Drive to file
C:\> SNAPSHOT C: X:\C-Drive.sna
this will backup the C: drive to X:\C-Drive.SNA.
To save several Volumes, simply create a Batch file like
SNAPSHOT C: \\Server\Backups\C-Drive.sna
SNAPSHOT D: \\Server\Backups\D-Drive.sna
SNAPSHOT E: \\Server\Backups\E-Drive.sna
This will backup C:, D:, E: to your server..
Option -L650
Most of the time, it's sensible to limit the size of a single image file to some maximum value, so it can be written to a CD-ROM. The default maximum size is 650MB; you can change this with the -L parameter.
To avoid trouble with DOS when restoring your drives, you should keep this below 2 GB.
Option -Ssize
Equivalent to Bytemode of Advanced Options.
-S0 -- always use Bytemode.
-S8192 -- use Bytemode, if clustersize is >= 8192
-S100000 -- never use Bytemode (default)
Option -R [empty Recycle bin ]
This will empty the Recycle Bin for this drive before starting the backup.
Option -W [Wait]
If the cursor is in the top left corner at the time of start, Snapshot assumes it has been started from a batchfile, and waits for the key at end, so you can control the execution.
This is probably unwanted, if it was started from the scheduler.
This WaitForAnyKey can be suppressed with -W.
Option -G [Graphical]
For those who have created a shortcut to a customized Snapshot command, but still want to see a graphical progress.
Useful if you have configured a shortcut or similar for automatic backup, telling the user 'Click here to backup your drive'.
It has a few sub modes like
-G show progress, wait for user to click [exit] when done
-Go show progress, exit when done if everything worked, else tell him so
-Gx show progress, always exit when done
Option -T [Test]
You can request a test of the image for validity, after it has been created.
This will completely reread the image and check its consistency, checksums,...
However (in particular in batchfiles) it's probably better to test the image separately ;like
snapshot x:\image.sna -T
so you can know whether a failure was due to the destination server being down, or 'unreliable data written'.
Any failure will be returned as Errorlevel > 0.
Differential Backups
please see differential.htm for detail
Set a Default Password from command line
-PW=MySuperSecretPassword
This password will be used for backup, restore, and mount from now on. Restore and mount will ask for the password, should it be needed.
Restoring a Volume
C:\> SNAPSHOT X:\D-Drive.sna D:
restores the D: drive from X:\D-Drive.sna. This will overwrite all data on the D: drive !!
The limitations are identical to the normal Snapshot Restore.
Setting the password from the command line
From the command line, you can set the password with -PW=
C:>Snapshot C: X:\Backup\c-drive.sna -PW=SuperSecret
This overrides a default password for this command only.
If you have a default password, and don't set one from the command line, the default is used.
If you have a default, but nevertheless don't want your image encrypted, you have to indicate an empty password:
C:>Snapshot C: X:\Backup\c-drive.sna -PW=
Excluding files/directories from backup
In some cases it can be useful to exclude some files or directories from backup.
That's always the case for (and is always done automagically) for PAGEFILE.SYS and HIBERFIL.SYS, but can also be useful for temporary files, big movie archives (which you have on the bought DVD anyway and similar stuff.
Due to technical reasons, the data in excluded files are not saved, but the directory entries ARE saved. Therefore, both when viewing the backup, and after restoring, the files *look* intact, but contain all zero's (when viewing) or random data (after restore).
For this reason, the image contains a fresh created Batch job 'SnapshotDeleteAfterRestore.BAT'.
After restore it should be executed to avoid possible confusion (it will delete all unsaved files).
Files and directories can be excluded by
--exclude:\Temp
--exclude:\Temp\* (which is equivalent)
--exclude:\Windows\Memory.dmp
options can be concatenated with commas like
--exclude:\Temp,\Windows\Memory.dmp,\Windows\Minidump\*,"\Documents and Settings"
,"\Program Files",\Windows\$NtUninstall* (1.38)
Note:
\temp and \temp\* are equivalent
Spaces in Filenames have to be enclosed by `"`
Subdirectories are also always excluded.
Creation of filenames with date, weekday, ...
Some 'magic' strings in the command line are replaced with the data, computer name, disk, etc.
So it makes sense to
c:\>snapshot C: \\server\backups\$computername\$DISK-$DATE.sna
$date Date 6-digit YYMMDD
$computername Computer name
$type for differential Images --> 'dif'
$disk the drive letter (C,D,...)
$weekday weekday, 2 letters
$year year (4 digits)
$month month (1..12)
$day day in month (1..31)
Mount a disk Image as virtual drive
C:\> SNAPSHOT X:\C-Drive.sna Z: -V
mounts the image X:\C-Drive.SNA as drive Z:
with a couple of variants:
-VM just mount the image, don't start Explorer
to be used in batch files
-VQ Z: mounts the volume, doesn't show any dialog
-!unmount:Z unmount Z:
-!unmount unmount all mounted drives (from 1.38)
Snapshot should be started with 'start' like
start Snapshot x:\image.bat Z: -vq
xcopy z:\Data c:\Data
Snapshot -!unmount:Z
Drive Snapshot 1.39 supports additionally File Extensions
--exclude:"\*.MP3,\*.TMP"
works as expected
[1.39]reparing damaged images
Unfortunately, images can be damaged. Some image sub-files may be missing or unreadable, data may be damaged, etc., and the image isn't mountable any longer.
As a disk image, this is useless as you will never know what data are missing.
But often all you need is a few files from the image. If the .SNA file is existing,
c:>snapshot x:\DAMAGED.SNA --repair:Y:\REPAIRED.SNA
will try to reconstruct something mountable; at least after running CHKDSK over the virtual drive you should be able to retrieve some data.
[1.39]Migration on different hardware
If you restore using VistaPE/BartPE, running
c:>snapshot --AddDriver
will ask you for the driver to be installed, and the location of the (restored) Windows, and install this driver as an additional disk driver
more special Options
snapshot --? shows all (documented ;) special commands
--unmount - unmount all virtual disks and terminate snapshot started with -VQ
--unmount:Z - unmount virtual disk Z
--resize X: - show possible resize range for drive X:
--resize X: 1000 - (try to) resize drive X: to 1000 MB
--resizepart X: 1000 - (try to) grow partition and filesystem to 1000 MB
resizepart is unable to shrink partitions or filesystems!
--exec:RestartExchange.Bat
--exec:"NET START ORACLE" - execute commands as soon as backup really started
MUST be the last option on the command line!
--ClearSignature HD1
--SetSignature HD1 01234567
--Checkboot HD1 - test if HD1 seems to be bootable
--Activate X: set active flag for drive X:
--Deactivate X: clear active flag for drive X:
--RestoreMBR HD1 filename - writes the MBR from filename to HD1
--RestorePartitionStructure HD1 filename -
writes the partition information from filename to HD1
--exclude:filename1,filename2,... excludes all given filenames from backup
--exclude:@filename.txt exclude from file filename.txt
--LogFile:filename.log - append log output to file filename.log
--DontLogStdout - don't write VSS log output to standard output
--DontLogProgress - don't write the progress report lines to stderr
--novss - don't use the volume shadow service (more about VSS)
--usevss - use the volume shadow service if available
--forcevss - use the volume shadow service. If not available exit with error.
--register:License.lic - register snapshot
--setdefaultpwd=MyPassword - sets the default password to MyPassword
--SearchFull:path1,path2,path3 while working with differential images
search the full image in the given path.
--------------------------------------------------------------------------------
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment