Simple Windows Server 2008 Backup Script

Filed Under (Windows Networking) by Just An Admin on 14-09-2012

If you have a NAS, storage server or maybe just a simple network disk, making a backup from Windows Server 2008 daily, with a month history is easy. Just use the batch script below. It makes folders based on the servername and a subdirectory based on the day of the month. If you schedule this backup each day, using the Task Scheduler, you would end up with 28 to 31 backups of history. I do weekly back-ups, as they fit my needs. This gives me 4 history backups.

The ‘wbadmin START BACKUP’ command can be altered to include the system state back-ups if you back up a Windows 7 or Windows 2008 R2 system. Look here for more options: http://technet.microsoft.com/en-us/library/cc742083%28v=ws.10%29.aspx



[cc width=”600″ lang=”vb”]

@echo off
:: backup-to-storage.cmd
:: Backup of <servername> using WBADMIN.EXE

:: Change settings below
rem backup share UNC
set backupshare=\\Storage\Backup

rem files and folders to include. Add drives or folder you want to include and separate with a ,
set include=c:
:: Do not change settings below

rem define date time variables for building the folder name
SET varYYYY=%DATE:~10,4%
SET varMM=%DATE:~4,2%
SET varDD=%DATE:~7,2%
SET varTodaysDate=%varDD%

rem defining a new folder like \\<networkdevice>\<backupshare>\<foldername>\<date>
set newfolder=%backupshare%\%computername%\%varDD%
echo Creating %newfolder%

mkdir %newfolder%

rem run the backup
echo Backing up %include% to %newfolder%
wbadmin START BACKUP -backuptarget:%newfolder% -include:%include% -allCritical -vssFull -quiet

[/cc]

Incoming search terms:

Comments:

(2) Comments for the first post!

Post a comment