Solved

ntbackup on server 2003 (r2) - automated scheduled local backups with retention?

Posted on 2006-07-18
11
1,757 Views
Last Modified: 2007-12-19
Hi,
Just wondering what the method is to use ntbackup to carry out say daily backups of a folder, to a local drive but do it in such a way that it holds on to previous copies of the backup for a specified period.
I could just use a scheduled batch file to move the newly created bkf file to another location etc, but there must be a better way?
0
Comment
Question by:budchawla
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 16

Assisted Solution

by:kshays
kshays earned 160 total points
ID: 17130499
Here is a small script that i've wrote to keep up with the backups.  You would need to mofidy it to your needs though, but you could check the date/time and if it's greater than a certain number of days then move/delete or whatever you would like.  I just have not taken the time to implement that yet.




@echo off
rem - -------------------------------------------------------------------
rem - Backups the Active Directory Server SystemState.
rem - Performs a normal backup.
rem - -------------------------------------------------------------------
rem i = Day of week
rem j = Month number
rem l = Year number

for /f "tokens=1,2,3,4* delims=.:/- " %%i in ('date /t') do (
  for /f "skip=1 tokens=1-4 delims=/-,()." %%x in ('echo.^|date') do (
  set weekday=%%i&set month=%%j&set day=%%k&set year=%%l))

for /f "tokens=1,2* delims=: " %%i in ('time /t') do (
  set hh=%%i&set min=%%j)

set filename=SystemState(%weekday%%month%%day%%year%-%hh%-%min%m)
ntbackup backup "@C:\BackupJobs\Backup_SystemStateNormal.bks" /f "e:\Backups\SystemState\%filename%_NORMAL.bkf" /v:yes /m normal




regards,

kshays
0
 
LVL 5

Accepted Solution

by:
beechfielder earned 180 total points
ID: 17130664
What I do is to use ntback to backup to a file on a nas server, then another script to copy the backup to anothermobile  drive using xcopy. I take this offsite. Basically we do what you mention above, but I have not found an easier way with ntbackup yet.

It might be a bit complicated but this would work

create a weekly schedule for each day of the week in ntbackup using the native scheduler.  With a file backup each day would need to use a different file name eg Monday.bkf etc

Then once a week xcopy the backup files to another location.   The next week the bkf files get overwritten and recreated.

Here is the small script I use for xcopy

xcopy "B:\server\*.*" "W:\offsite backups\" /E /C /H /Y
0
 
LVL 10

Author Comment

by:budchawla
ID: 17131395
thanks for both comments guys...
kshays.. I'm sure your method is great, but I think what beechfielder's method lacks in sophistication, it makes up in simplicity!
Add to that the fact that I would have to customise the script to handle the deletion (which would take me even longer to figure out), I think I'll go with the second suggestion for now.
What I was hoping for is a better method than the scripting of a copy operation, maybe something integral to the ntbackup utility that I'd missed. I'll leave this question open a wee bit longer in case someone comes up with something much nicer..
0
 
LVL 16

Expert Comment

by:kshays
ID: 17131864
True, I basically use that script so I can append the names of the diff files I do daily is all.  Looks complicated at first, but it isn't too bad though :)  I'm sorta interested in seeing what everybody else uses if they do use ntbackup for their backup solutio as well :D


kshays
0
 
LVL 5

Expert Comment

by:beechfielder
ID: 17133028
Yes I am interested to see how others do it too.  I am in the process of getting Acronis server and adding that to the schedule of backups.  I think even just to have an old image of the whole server would be a good thing and save having to reinstall Windows and all the apps and do all that configuration.

I am also using exmerge each night, which is very fast and means I can restore an individual mail box if necessary.  Belt and braces as we say in the UK!
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Assisted Solution

by:SkUllbloCk
SkUllbloCk earned 160 total points
ID: 17136994
Well this isnt really an answer to your question

I also use a script like kshays has,
mine will move the backup to a new folder that is created by date (the date of the file) and also keeps x amounts of copy's, aswell as logs the process so that you can check up on it later.
If you want this script to run on multiple files all you need to do is add a new "module", with the particulars in it.

Here is the code for the Backup_Sort.bat file
________________________________________________________________________________
: Start Of Batch File
: ===============
      @ECHO OFF
      SETLOCAL ENABLEEXTENSIONS
      ECHO START OF LOG     %DATE%     %TIME%
      ECHO.
      ECHO.
      CALL :First_Module
      GOTO :End
: ****************************************
: * START OF MODULE SECTION *
: ****************************************
: Process First Module
: =================
:First_Module
      SET bkBackup=First_Module
      SET bkLocation=E:\Backup Files\
      SET bkType=*.bak
      SET bkCopies=1
      CALL :Step1
      GOTO :EOF
: *************************************
: * END OF MODULE SECTION *
: **************************************
: *******************************************************
: * START OF COMMON PROCESS SECTION *
: *******************************************************
: STEP ONE      Retrieve Date
: =======================
:Step1
      ECHO =================================
      ECHO %bkBackup%     %DATE%     %TIME%
      ECHO =================================
      E:
      CD\
      CD %bkLocation%
      ECHO.
      FORFILES /M %bkType%  /C "CMD /C ECHO @FDATE/@FILE >> Files.log"
      FOR /F "TOKENS=1-4 DELIMS=:/- " %%A IN (
            Files.log
      ) DO (
            SET bkDay=%%A
            SET bkMonth=%%B
            SET bkYear=%%C
            SET bkFile=%%D
            CALL :Step2
      )
      CALL :Step3
      DEL /Q Files.log
      GOTO :EOF
: STEP TWO      Create Folders And Move Files
: ====================================
:Step2
      SET bkFolder=%bkYear%-%bkMonth%-%bkDay%
      SET bkFile=%bkFile:~1,-1%
      IF NOT EXIST %bkYear%-%bkMonth%-%bkDay% (
            MKDIR %bkYear%-%bkMonth%-%bkDay%
      )
      ECHO Moving %bkFile% to %bkFolder%
      MOVE /y %bkFile% %bkFolder%
      ECHO.
      GOTO :EOF
: STEP THREE      Delete Old Files And Folders
: ===================================
:Step3
      DIR /AD /B /O-N > OldLocations.log
      FOR /F "SKIP=%bkCopies%" %%A IN (
            OldLocations.log
      ) DO (
            ECHO Deleting %%A
            RMDIR %%A /S /Q
            ECHO.
      )
      DEL /Q OldLocations.log
      GOTO :EOF
: ****************************************************
: * END OF COMMON PROCESS SECTION *
: ****************************************************
: End Of Batch File
: ==============
:End
      ECHO.
      ECHO END OF LOG     %DATE%     %TIME%
      ENDLOCAL
________________________________________________________________________________

Please Note that the these entries are variable values that are defined in teh module section:
bkBackup , bkLocation , bkType , bkCopies

bkBackup is any name you want to give the backup, this makes it easy to find in the log files generated by the next batch file (Backup_logger)
bkLocation is the location of the backup files (where NTBackup stores them)
bkType is the filename extension (or full name of the backup File)
bkCopies is the number of copies you would like to keep.

ALSO Note that depending on your date/time settings you might need to change the bkDay bkMonth bkYear variables arround in step 1


Here is the seccond batch file "Backup_Logger.bat"
________________________________________________________________________________
: Run Sort Batch File
: ===============
:Sort
      @ECHO OFF
      FOR /F "TOKENS=1-7 DELIMS=:/-. " %%A IN (
            "%DATE%"
      ) DO (
            SET LogDay=%%A
            SET LogMonth=%%B
            SET LogYear=%%C
      )
      ECHO The Backup Sort File Was Started.
      CALL "Backup_Sort" > %LogYear%-%LogMonth%-%LogDay%-Backup.log 2>&1
      GOTO :End
: End Of Batch File
: =============
:End
________________________________________________________________________________

Please note that depending on your date/time settings you might need to change the LogDay LogMonth LogYear variables arround.

ALSO note that the "Backup_Logger.bat" file is the file that needs to be run, the other file is called by this file.


With this script you can also use it for your exmeged files, just add a new module with the location of the files , file type, and number of copies.
The files will be copied to a sub Directory (folder is the name of the date of the files)
0
 
LVL 16

Expert Comment

by:kshays
ID: 17137539
Excellent script there SkUllbloCk  :)  Actually that looks sorta what I was going to do with my small script, I just had not had time yet to sit down and do it though.

Cheers,

kevin
0
 
LVL 10

Author Comment

by:budchawla
ID: 17519600
Thanks for all your input guys - excellent stuff, and any split of points is likely to be unfair, since all 3 are workable solutions, however I guess I should "Accept" the solution that I actually used, and that was beechfielder's, so points split and answers accepted - thanks once again and apologies for going silent!
0
 
LVL 10

Author Comment

by:budchawla
ID: 17519604
Thanks for all your input guys - excellent stuff, and any split of points is likely to be unfair, since all 3 are workable solutions, however I guess I should "Accept" the solution that I actually used, and that was beechfielder's, so points split and answers accepted - thanks once again and apologies for going silent!
0
 
LVL 5

Expert Comment

by:beechfielder
ID: 17520093
Thanks for the points budchawla
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have never ceased to be amazed how many problems you can encounter on a fresh install of a Windows operating system.  This is certainly case in point& Unable to complete ANY MSI installation.  This means Windows Updates are failing and I can't …
So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now