Zedan IT Blog

IT definitions, discussions and more

Simple Windows Server Backup Script – Part 1 2003


“Backup”  is a word every system administrator feel shake in his body when
someone mention something wrong about it.   Every system , should have its
backup and backup/restore procedure.  I will not get more into explain what
backup is and why it is important.

I remember when working with Windows NT 4.0 about 12 years ago how it forced us
to use backup on tapes, and how we must wait till the tape end catalog, and how
it took very long time to backup or restore,  unless you had the budget to buy
special backup software.   Also I remember how it was great when we found that
we can take an image of the entire disk using programs like Norton Ghost.

Fortunately , things are better now, if you did not get approval for buying
expensive backup software, you still can use automatic scheduled backup wit
archiving of old backup.   Here I will present two simple solutions for windows
2003 & 2008 using what we already have in the server like NTBACKUP and WBADMIN.

Here, I will present two scripts to give you an idea about using the command
line backup tools and schedule to run on daily basis and an example of
archiving:

Suppose that you have 2003 server (Server01) and you want to schedule backup for
System Drive C: , System State, and a data folder on Drive D:

1-  Make a selection of what to back and save it as a selection file.

Start Windows Backup, or from the command prompt run ntbackup.exe (start
in advanced mode, not the wizard mode)
.  Go to Backup Tab and
select Whole Drive C: and the folder in Drive D:  and Do not forget to check the
System State.

2- From Job Menu, save your selection as a .bks file.  E.g.  D:\Scripts\Winbackup.bks


3- Suppose you will take backup every day to drive X: and you want to keep the
backups of yesterday and the day before yesterday accessible.    Example, create
three folders in drive X: (Today, Yesterday, Old).

4- Create a batch file to execute ntbackup with the saved selection into Today
Folder, while keeping the backup of Yesterday and the day before:

    X:    cd\

    cd old

    del *.* /q

    cd ..

    rd old

    ren Yesterday Old

    ren Today Yesterday

    md Today

Then add the command to execute the NTBACKUP:

C:\Windows\system32\NTBACKUP.EXE
backup “@D:\scripts\WinBackup.bks” /n “Server01” /d “Server01 %date% %time%”
/v:yes /r:no /rs:no /hc:off /m normal /j “Server01 Daily Backup” /l:s /f
“X:\Today\Server01_Win.bkf”
 

5- Save the batch file into your “D:\scripts”  folder
as  “DailyBackup.bat”.
You can test the script by double click on the .bat file in windows explorer or
by opening the command prompt ( Start > run > cmd > press Enter)  then type
“d:\scripts\dailybackup.bat”

You will notice that will create the  folder “Today” in
X: then will create the backup file “Server01_Win.bkf”
inside it.   After the backup finish, if you execute the batch file again, the “Today” folder
will be renamed to“Yesterday” and
a new Today folder will be created.

If you execute it once more, the “Yesterday” folder
will be renamed to “Old”,
and “Today” folder
will be renamed to “Yesterday”,
and so on….

By Executing this simple script you will have a full backup for the past three
days,  you can increase the number of archives as you need by changing the
script.  For example by creating folders with the names of week days.

6- Now schedule the DailyBackup.bat to run on daily basis at a specific time,
Let’s say you want it to be automatically executed everyday at 3:00 AM.

In windows 2003,  open the Task Scheduler:     Control Panel > Add Scheduled
Task




Click Next, Then Click Browse and select the batch file you saved in step #5


Give a name to your scheduled Task, and select Perform this task Daily


Click Next to Select the Time to run the Task automatically


Click Next and Enter the Credentials of and Administrator or Backup Operator
Account,  Click Next then Finish.

You can Review the Daily Backup Task report from the Log Viewer in Task
Scheduler, and The Backup Report from The report viewer in NTBACKUP.

Also, it is wise to copy the Created BKF file to an external Storage on Daily
Basis.

In Part 2, I will explain hot to create a batch file with the WBADMIN backup
tool for windows 2008.

 

8 responses to “Simple Windows Server Backup Script – Part 1 2003

  1. Pingback: نسخ ويندوز سيرفر إحتياطيا بسهولة وبدون تكلفة « زيــــــدان اون لايــــــــن

  2. Pingback: New Software/Repository Backup & Restore Scripts | xjonquilx | Mepis, Ubuntu, Fedora, Linux, Oh My!

  3. Pingback: Simple Windows Server Backup Script – Part 2 2008 « The IT Blog

  4. Pingback: Daily backup script for MDaemon (or other servers) « Zedan IT Blog

  5. Damon 31/07/2013 at 4:13 AM

    Hi, yes this paragraph is actually good and I have learned lot of
    things from it concerning blogging. thanks.

  6. mugilan 03/10/2014 at 9:00 AM

    hi
    It works upto creating a folder today after that no backup running creating in that folder.

  7. Zedan 06/10/2014 at 3:35 AM

    Hello, did you add the ntbackup command to your script?

    • mugilan 08/10/2014 at 10:12 AM

      Hi

      Thanks a ton.Now it working fine.I made some mistakes while adding the script and then i corrected it now its working fne.Once again thanks a lot!!!!!

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s