Thursday, August 14, 2014

Backup/Copy Files that are “Open” or “Locked” Using a Simple Batch Script

Backing up files is a very critical function which guarantees business continuity and recovery after an unforeseen disaster such as theft, machine malfunction, sabotage, human error or a virus infection.

There are various approaches and tools that organizations are using towards securing their data particularly what sits on individual employees’ computer hard drives.

One of the more common ones is the technique of mapping My Documents folder to a home drive that sits on a central server and then enabling Offline Synchronization.

Though this approach is highly recommended it leaves out email data i.e. PST files (Microsoft Outlook Email Format). PST files cannot be copied or synched when Microsoft Outlook is open. Usually, you’ll get an error saying the file is locked or in use.

So how does one copy or backup locked or open files? The answer is using a nifty tool called HoboCopy.    

HoboCopy support a feature called Volume Shadow Service (VSS) which enables one to copy/backup open files such as PSTs.

Following this discovery I’ve developed a simple batch file to do the job. Combine this file with Windows’ Scheduled Task feature, and you have an easy method for backing up files automatically.
  • Download HoboCopy (32 or 64bit Version) - https://github.com/candera/hobocopy/downloads
  • Copy it on the root folder e.g. C:\hobocopy
  • Copy the batch script to the root folder too e.g. C:\backupscript.bat . A sample of the script is as follows:

Other References:
http://www.howtogeek.com/howto/windows-vista/backupcopy-files-that-are-in-use-or-locked-in-windows/

No comments:

Post a Comment