Link to home
Start Free TrialLog in
Avatar of goodforit
goodforitFlag for Afghanistan

asked on

How to create individual differential backup files in SQL 2005

I'm fairly new to backing up SQL Databases and need detailed instructions to perform a differential backup.  I have it backing up, but it just creates on file and keeps adding to it every 2 hours.  I need to basically have one large full backup and just have small differential backups every two hours in the form of a separate file.  This is on SQL 2005 and I'm using the Studio Manager to setup the backups.
Avatar of dbidba
dbidba
Flag of United States of America image

BACKUP DATABASE <<DbName>> TO DISK = '<<Path\FileName.bak>>' WITH DIFFERENTIAL

Pass a different file name to the backup each time. I append the date-time into the filename.
i.e. d:/SqlBackup/SomeInstance/SomeDatabase/Diff/DbName-diff-20100106-032722.bak

ASKER CERTIFIED SOLUTION
Avatar of Ayman Aboualnour
Ayman Aboualnour
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
From Management Studio:
- Managements --> right click Maintenance Plan --> New Maintenance Plan
- From tool box drag and drop  "Backup Database Task"
- Right click on Backup Database Task you just created and Click Edit
- Select backup type to be Diffrential
- Choose the database you want to backup
- select the folder of backup files destination
- press Ok
- Press Schedule
- Select Occurs Daily and  Check Occure every 2 Hours
- Starting at "your start time" and "ending at your end time" of your working time.

--- make the same for the full backup but specify weekly
save



Avatar of goodforit

ASKER

Thanks for the help so far.  How do I "append the date-time into the filename"?
Something like this:

select
   @BkuFilNa = @BkuPthNa
   + @pDbNa
   + '-'
   +  case
      when ( @pBkuTyp = 'F' )
         then 'Full'
      when ( @pBkuTyp = 'D' )
         then 'Diff'
      when ( @pBkuTyp = 'T' )
         then 'Tran'
      end
   + '-'
   + convert(varchar(20), getdate(),112)
   +'-'
   + replace(convert(varchar(20), getdate(),108),':','')

This assumes that you are creating the backup command in code (in a scheduled job) and dynamically executing it.
Is there a way to do it through the Studio Manager and not through code?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial