Friday, August 23, 2013

Use an automated backup script that will check your backup drive letter.

I have tried many different tools for automated backup, both third party and the ones built into windows, but the best one by far is Robocopy. It is the most robust, stable and reliable tool that you'll ever find to automate backups both in the enterprise environment and at home.

I use Robocopy scripts to mainly create backups onto an external USB drive that can be routinely taken offsite and switched with another external drive.
The biggest problem when using automated backup onto an external drive is the fact that the letter of the drive may change at some point if the drive was unplugged and then re-plugged. This causes your backup procedure to miss the target drive and backup will not run.

Here's an example of a script that overcomes the problem of the changing drive letter.

In this example we run a mirror backup of a server folder onto an external backup drive, and the script will find out whether the backup drive is using drive letter G: or H:

@echo off

IF exist G:\ident.txt (goto run1) ELSE goto run2

 :run1

 robocopy "\\Server\Administration" "G:\Backup\Administration" /MIR /W:0 /R:0 /XF:SHT /LOG:backuplogr.txt /NS /NC /NFL /NDL /NP

 :run2

 robocopy "\\Server\Administration" "H:\Backup\Administration" /MIR /W:0 /R:0 /XF:SHT /LOG:backuplogr.txt /NS /NC /NFL /NDL /NP

We start by creating a procedure that will check for a file called "ident.txt" (could have any other name or extention) - this is an empty file you should create and put in the root folder of your backup drive.
So if the file is present on drive G: - we point the script to a label called "run1" which runs the backup to drive G:. If the file is not present on drive G: (or if there IS no drive G:) we bounce the process to the label called "run2" which will then run the backup onto drive H:.

Robocopy then starts backing up a shared folder called "Administration" located on a server named "Server" onto the the external USB drive.

No comments:

Post a Comment