Workstation Open File Backup Using Robocopy And Vshadow


By Robert Jeffery
Printer Friendly Version
  

A simple dos script that copies data from a workstation including open files, and some help on backing up multiple workstations while keeping the backup size small and accessible.



Hello, I work for a small company with lots of users who were losing data, or needing previous versions of files even if they had been completely deleted. With the added benefit of being able to repair a system if a disk should fail etc. Not being a programmer I managed to find a way around this by using freely available code and some DOS programming.

 

Requirement.

 

The user wanted the ability to see and restore files and folders themselves with previous versions.
A full backup of a system that will run in the background while the user is unaware.

A full backup of a system that includes open files and system files.

A full backup that will not take too much time, CPU or bandwidth on the workstation.

The backup store will be as small as possible.

The backup to run at a regular time intervals.

 

History.

 

Previously users copied files using a simple Robocopy script to backup their documents and settings to a server share. This is great once you have done the initial copy as it only copies changed / newer files and removes files from the destination when no longer on the source. However this was rarely done as the user would forget to run the script until it was too late.
The problem was that after a while people wanted to recover files in other directories not just in their documents and settings folders. This would have led to a massive increase of storage for the backups. Also files in use were not backed up like pst files as Robocopy cant copy a file in use.


Solution.

 

There are lots of free and paid for applications that do full or incremental shadow backups but we needed a simple solution without installing programs everywhere that created massive image files of each machine.

 

1. User access to backed up files and previous versions.

It had to be files on a share. Easy, create a shared folder on a server for all the machines files to be copied to. Robocopy can copy security info stopping unwanted assess from other users.

Enable Shadow copies for the volume holding the share on the server. (Windows 2003+) this gives the user the option to see a previous version of a file/folder.

 

2. Shadow copies for open files

I found some useful steps on eggheads for using vshadow so worked from that to set up a simple backup script and finally came up with this.

 

3. Backup storage space.

In our case 30 machines with an average of 27Gb on their C: drives would be about 800Gb+ of storage. As most of our workstations data is identical windows system files, and the program files etc I used a very handy utility to save space once copied to the server. Microsoft’s Single Instance Storage (SIS) is a utility that finds multiple identical files within its directories and stores a single copy that is cross linked in the file system. Usually SIS comes with Windows storage server only, however it can be used within at least windows standard by installing Windows deployment services (for OS instillation of workstations over the Lan) and only using it for its SIS capabilities. This creates a shared folder on the server that can be used for the destination backup store. Another shared folder within this could easily work too just for the backup. Using this method with windows file compression brings down our storage to about 300Gb. However I’m not so sure the windows compression makes much difference.

 

The scripting.

 

The complicated bit is the scripting which would be simple if we wanted to just pull the data from a workstation to a server somewhere, but this wouldn’t fix the open file issues. So I used my limited DOS skills to alter another eggheads script which used vshadow.exe to copy open files.

The new script runs Vshadow.exe which created a snapshot of the c: drive, then calls another script where Dosdev.exe maps the snapshot of the c: drive to be semi visible as the b: drive on the workstation. Robocopy.exe then copies changed files from the b: drive to the server. Viola! The b: drive is that unfortunately Robocopy.exe cannot copy straight from the shadow volume so Dosdev.exe helps here.

Once this script exits and returns to the Vhsadow.exe process the snapshot is deleted on the workstation and the job is done.

 

You will need the following in the same directory as the scripts or installed on the workstation. Vshadow.exe from Microsoft msdn site. Robocopy.exe from Microsoft’s windows support tools download section. Dosdev.exe I cant remember where I got this but if you Google dosdev.exe you’ll find it.

 

The command that starts the backup. (local admin rights needed);

 

vshadow.exe -script=vss-setvar.cmd -exec=vss-exec.cmd c:

 

The vss-exec.cmd script that is called from Vshadow.exe. Create vss-exec.cmd file containing:

 

call vss-setvar.cmd

@ECHO OFF

dosdev B: %SHADOW_DEVICE_1%

robocopy B:\ \\server\share\ /mir

dosdev -r -d B:

 

The above is all you need to start copying everything to a share on a server but the destination could be anything like a USB hard drive.

!! The first time you run this all the files will be copied to the destination so I suggest running when quiet.

It also doesn’t exclude some big files that are not needed. Try adding “/xd *"System Volume Information" *"temporary internet files" *temp *RECYCLER $* /xf pagefile.sys hiberfil.sys *.bak *.cmf  /w:0 /r:0” to the robocopy line.

 

The final solution.

 

In my situation I wanted to control when the backups fired off especially for the first big run so I used psexec (see Microsoft remote execution tools) to start it remotely as a low priority on all our workstations, and monitor it. Also I put the vss-exec.cmd file on a share elsewhere where it couldn’t be tampered with. Dosdev.exe, robocopy.exe and vshadow.exe are in the c:\windows directories on each workstation.

 

@names.exe is a file with all the computer names on each line.

\\Store is the server where the workstation backup files are kept and in our case uses SIS too, but also the vss-exec.cmd is kept away from tampering with in the shadowback$ share.

 

Execute:

 

psexec @names.txt -low -e -a 0 -u crick\domainadminusername -w c:\ "vshadow.exe" -script="vss-setvar.cmd" -exec="\\store\shadowback$\vss-exec.cmd" c:

 

Vss-exec.cmd located on the server contains;

  

call vss-setvar.cmd

 

@ECHO OFF

dosdev B: %SHADOW_DEVICE_1%

 

robocopy B:\ \\store\reminst\computers\%computername%\c$\ /mir /sec /log:c:\backup.log /np /xd *"System Volume Information" *"temporary internet files" *temp *RECYCLER $* /xf pagefile.sys hiberfil.sys *.bak *.cmf  /w:0 /r:0

 

dosdev -r -d B:

 

Conclusion

 

The above works very well for us using robocopy however using rsync or xcopy should work well too.

I hope this helps some IT manager or developer in their solutions.



Biography
IT manager for a small software house having been in the IT trade for 15 years, and before that in Electronics. Not specializing in anything but being a "Jack of all trades" especially in the Microsoft range.

button

 
Article Discussion: Workstation open file backup using Robocopy and Vshadow.
Robert Jeffery posted at 07-Jan-08 10:27
Original Article

 
Perfect
Denys Firth replied to Robert Jeffery at 02-Mar-08 05:11

What a perfect solution!

I have been using vshadow with the vss.exec command plus dosdev (in XP), plus rysnc, to backup both on the lan and over the internet, using ssh. Itefix's cwrysnc helped as did Adi on the vshadow side.

Problems are that rsync does not like long file names (>256) and is quite slow. But it wins for backups involving .pst files which can be GBs in size, especially over the internet, because it only transfers the block differences not the whole file. This very substantially reduces network traffic and time for .pst files. It is marginal for most other types of file. I guess.

My solution to longfile names is to get everyone to use a new ubuntu linux pc with samba as a file server. Also rsync is much faster in linux when I backup the file server (and no longfile name problems). But people will need to store .pst files locally and will always want to save some files on desktops etc. Backup is absolutely critical for us.

Two questions if I may. Is backing up the whole disk really worth it? I know I have a huge problem because each person stores files in different places. It seems simple. Our setups are all quite similar. But do the backups take for ever, and can you really re-install windows easily from the backup? Does SIS work in XP prof?

Second question relates to psexec (I have been looking for this!). Can it copy more than one file over (eg could I cope over all the files (vshadow, dosdev etc) so that I have no need to store anything locally. This I guess would help on the automation, especially if I can get people to store files only in limited, but similar places so that I can fix the location without backing up the whole drive.

Many thanks


 
vshadow backup
Robert Jeffery replied to Denys Firth at 03-Mar-08 04:37

Hello Denys, Glad to hear your using the scripts and it is working well. I must admit I used rsync to backup and found it too slow too, Ill have a look at backing up to Linux  with Rsync when I have some spare time. I did hear that there are ways to speed up Rsync especially with windows. Ive set it up so workstations on the road cant see the backup server and dont have to slowly backup, most remote users come into the office at least once a month so we at least get some copy of their data.

As for the backup of the whole disk essential, well probably not but I havnt had to restore a complete system yet but there has been one occasion where the registry needed restoring after a system wouldnt boot and just by booting BartPE and restoring this file worked fine. Once the first copy has been run with robocopy (slow even on LAN) further backups run so fast its not an issue with speed as it parses folders so quickly, but yes you could easily speed up the whole process with just the My documents folders being backed up. The storage SIS isnt an issue as duplicated files are saved once on the server which is why I didnt mind backing up nearly everything on the c: drive. The XP system restore stuff would have killed the storage if I allowed that to be copied. Unfortunately Ive never heard of SIS for anything other than Win servers however there are other equivalents you can buy, cant remember their names. I would love a similar free product for Linux and Id convert the server straight away.

As for your psexec question I think you are asking if PSexec can itself copy the vshadow/dosdev files, well Im sure it cant but its nothing to copy these files to someones drive in a logon script, or you could easily keep all the files on the workstation just by simple change to the scripts, I left some of these on the server so to stop some people changing this.

I hope I have answered some of your questions.


 
Robocopy
Denys Firth replied to Robert Jeffery at 03-Mar-08 04:43
Most helpful. It is interesting how fast Robocopy is compared to rsync in windows (rsync is much faster in linux to linux). Efficient backup is a fascinating field for research.

 
backup
Robert Jeffery replied to Denys Firth at 03-Mar-08 04:54
There is something I remember about getting rid of the ssl in rsync terminal session it creates back to the server. One day I will have a look.

 
Robocopy
Denys Firth replied to Robert Jeffery at 03-Mar-08 05:00
Interesting. BTW, drectories with long file names really seem to slow it down. Not sure why. I have wondered whether all the ownership and security checking and synchronization slow it down