Would you like to have a process that will back up all your shared folders onto a WHS Unmanaged Disk (generally external) on a pre-arranged schedule of your choosing? Would you like to also copy the WHS backup database? If you are interested, keep reading... To start you will need to
install Robocopy, which can either be installed as part of the Windows 2003 Server resource kit, or by itself, from the link at the top of this article:
http://technet.microsoft.com/en-gb/magazine/2006.11.utilityspotlight.aspx . (The downloaded file is a self-extracting ZIP. Extract the files to a temporary location on your WHS server and then run the setup. RoboCopy will be installed. The article describes RoboCopy.
Then you will need to know the disk to which you wish to save the backups (E:, F:, etc). The script ass-u-me-s that the target drive is E: and needs to be modified in five places if that is to be changed (one early comment line and then for the two RoboCopy and two Xcopy command lines).
Copy the code below into a file to save in your WHS. I have named this Automatic.bat and saved in the root directory of the c: drive (C:\).
Added 19 Jan 10: You also need to add the target directory for the log files that are created (or modify the script to not create them -- NOT recommended). The default target directory to be created is
C:\WHS Backup Logs\. Note that the first few executions WILL generate errors for the "rename" commands as prior logs do not exist. These may be safely ignored. (THANKS to "Lazar" for pointing these out!)
Test the code on your server before automating it, running it from a remote desktop. (Can either do this from a command prompt or by navigating to the file and double-clicking.) Be aware that on the first use the entire process will probably take a goodly number of hours. After the initial backup is complete nightly backups are MUCH faster. Initial use for me was around 20 hours, daily backups now take 30-40 minutes. (The Sunday backups do take considerably longer as the backup database is significantly reconfigured as part of the weekly cleanup; for me this is about 7 hours.) All of this is in the background and the server can be used as this is running although I would avoid having this overlap with the nightly backup window.
Each time the routine is run the RoboCopy progress is captured in a pair of log files, one for the backup database and one for the shared folders. Nine logs are kept for historical reference with the oldest being erased each time and the others renamed. They will be stored in the C:\ root directory.
AFTER the initial use of the routine and after you are comfortable with letting it run unattended, this can be scheduled to execute at intervals of your choice. (I run this 30 minutes after my nightly backup window is over, in the morning hours when there is little load on my swerver.) You can do the scheduling from Start --> Control Panel --> Scheduled Tasks --> Add Scheduled Task
The following code is the most current (as of 7 July 09) and will be updated as it changes. The code segment immediately following this is the original and other code in this thread may not be current.Edited 18 Jan 10 to change the default target drive to E: to match the original.Code:
REM Windows Home Server backup of backup folder and then shares folder
REM This assumes the target drive is the E-Drive (E:). Change targets appropriately if using a different drive.
REM This currently defaults to using XCOPY. If the use of RoboCopy is preferred comment out the XCOPY lines (2) and
REM remove the comments ("REM ") from the Robocopy command lines (2). Note that RoboCopy must be installed to use Robocopy!
REM A Critical Error will be present on the server when the Backup Database is being backed up as the Backup Service will be shut down.
REM (This may be safely ignored as it will be restarted at the completion of the database backup -- before the Shared Folders are copied.)
REM Log files will be created in C:\WHS Backup Logs\
REM (C) 2008 www.HomeAutomation-Direct.com - Modified by JohnBick December 2008, Jan 2009, May 2009
REM Released under GPL. No consequential loss or damages accepted. Use at your own risk!
REM WHS will complain if the services are stopped for too long!
REM ------------------
REM Copy the WHS CLIENT BACKUP Database
REM Stop the Drive Letter Service
NET STOP PDL
REM Stop the Backup Service
NET STOP WHSBackup
REM Select one copy method OR the other below.
REM ROBOCopy the "backup" folder in Mirror Mode, Restartable, All attributes, No progress, 4 retries, 5 second wait between retries, Log to file, Console output
REM Robocopy D:\folders\{00008086-058D-4C89-AB57-A7F909A47AB4} E:\Backups\{00008086-058D-4C89-AB57-A7F909A47AB4} /MIR /Z /COPYALL /NP /R:4 /W:5 /LOG:"C:\WHS Backup Logs\External-Backups.log" /TEE
REM Copy the "backup" folder
XCopy D:\folders\{00008086-058D-4C89-AB57-A7F909A47AB4} E:\Backups\{00008086-058D-4C89-AB57-A7F909A47AB4} /D /E /V /C /I /G /H /R /K /X /Y >"C:\WHS Backup Logs\External-Backups.log"
REM Start the Backup Service
NET START WHSBackup
REM Start the Drive Letter Service
NET START PDL
REM -------------------
REM Rename the log files to save last TEN (0-9)
erase "C:\WHS Backup Logs\External-Backups-9.log"
rename "C:\WHS Backup Logs\External-Backups-8.log" External-Backups-9.log
rename "C:\WHS Backup Logs\External-Backups-7.log" External-Backups-8.log
rename "C:\WHS Backup Logs\External-Backups-6.log" External-Backups-7.log
rename "C:\WHS Backup Logs\External-Backups-5.log" External-Backups-6.log
rename "C:\WHS Backup Logs\External-Backups-4.log" External-Backups-5.log
rename "C:\WHS Backup Logs\External-Backups-3.log" External-Backups-4.log
rename "C:\WHS Backup Logs\External-Backups-2.log" External-Backups-3.log
rename "C:\WHS Backup Logs\External-Backups-1.log" External-Backups-2.log
rename "C:\WHS Backup Logs\External-Backups-0.log" External-Backups-1.log
rename "C:\WHS Backup Logs\External-Backups.log" External-Backups-0.log
REM Backup Database backed up, backup service has been restarted, and logs saved
REM -------------------
REM Backup the WHS SHARES folder
REM Select one copy method OR the other below.
REM Copy the “shares” folder in Mirror Mode, Restartable, All attributes, No progress, 4 retries, 5 second wait between retries, Log to file, Console output
REM Robocopy D:\shares E:\Shares /MIR /Z /COPYALL /NP /R:4 /W:5 /LOG:"C:\WHS Backup Logs\External-Shares.log" /TEE
REM Copy the WHS Shared Folders
XCopy D:\shares E:\Shares /D /E /V /C /I /G /H /R /K /X /Y >"C:\WHS Backup Logs\External-Shares.log"
REM -------------------
REM Rename the log files to save last TEN (0-9)
erase "C:\WHS Backup Logs\External-Shares-9.log"
rename "C:\WHS Backup Logs\External-Shares-8.log" External-Shares-9.log
rename "C:\WHS Backup Logs\External-Shares-7.log" External-Shares-8.log
rename "C:\WHS Backup Logs\External-Shares-6.log" External-Shares-7.log
rename "C:\WHS Backup Logs\External-Shares-5.log" External-Shares-6.log
rename "C:\WHS Backup Logs\External-Shares-4.log" External-Shares-5.log
rename "C:\WHS Backup Logs\External-Shares-3.log" External-Shares-4.log
rename "C:\WHS Backup Logs\External-Shares-2.log" External-Shares-3.log
rename "C:\WHS Backup Logs\External-Shares-1.log" External-Shares-2.log
rename "C:\WHS Backup Logs\External-Shares-0.log" External-Shares-1.log
rename "C:\WHS Backup Logs\External-Shares.log" External-Shares-0.log
REM Shared Folders backed up and logs saved
This is the original code: Code:
REM Copy WHS Backup Database and Shared Folders to an unmanaged disk drive
REM This script assumes the target is Disk E: -- modify script in two places if that is to be changed
REM The logs are placed in the C:\root directory. That can also be changed (22 places)
REM A Critical Error will be present on the server when the Backup Database is being backed up as the Backup Service will be shut down.
REM - This may be safely ignored as it will be restarted at the completion of the database backup
REM Backup the WHS BACKUP DATABASE
REM Stop the Backup Service
NET STOP PDL
NET STOP WHSBackup
REM Copy the "backup" folder in Mirror Mode, Restartable, All attributes, No progress, 4 retries, 5 second wait between retries, Log to file in c:\temp, Console output
Robocopy D:\folders\{00008086-058D-4C89-AB57-A7F909A47AB4} E:\Backups\{00008086-058D-4C89-AB57-A7F909A47AB4} /MIR /Z /COPYALL /NP /R:4 /W:5 /LOG:"C:\External-Backups.log" /TEE
REM Start the Backup Service
NET START WHSBackup
NET START PDL
REM Rename the log files to save last NINE
erase C:\External-Backups-1.log
rename C:\External-Backups-2.log External-Backups-1.log
rename C:\External-Backups-3.log External-Backups-2.log
rename C:\External-Backups-4.log External-Backups-3.log
rename C:\External-Backups-5.log External-Backups-4.log
rename C:\External-Backups-6.log External-Backups-5.log
rename C:\External-Backups-7.log External-Backups-6.log
rename C:\External-Backups-8.log External-Backups-7.log
rename C:\External-Backups-9.log External-Backups-8.log
rename C:\External-Backups.log External-Backups-9.log
REM Backup Database backed up, backup service has been restarted, and logs saved
REM Backup of the SHARES folder
REM Copy the shares folder in Mirror Mode, Restartable, All attributes, No progress, 4 retries, 5 second wait between retries, Log to file in c:\temp, Console output
Robocopy D:\shares E:\Shares /MIR /Z /COPYALL /NP /R:4 /W:5 /LOG:"C:\External-Shares.log" /TEE
REM Rename the log files to save last NINE
erase C:\External-Shares-1.log
rename C:\External-Shares-2.log External-Shares-1.log
rename C:\External-Shares-3.log External-Shares-2.log
rename C:\External-Shares-4.log External-Shares-3.log
rename C:\External-Shares-5.log External-Shares-4.log
rename C:\External-Shares-6.log External-Shares-5.log
rename C:\External-Shares-7.log External-Shares-6.log
rename C:\External-Shares-8.log External-Shares-7.log
rename C:\External-Shares-9.log External-Shares-8.log
rename C:\External-Shares.log External-Shares-9.log
REM Shared Folders backed up and logs saved
Future PlansIn the near future I will post an expanded version of this script that uses TrueCrypt to encrypt the target drive and add additional protection for the off-site storage of the backup. When I do that I will edit this post and add a link to that thread here.
If there are any changes to the script above I will update this post to make the changes.