Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to trim .bak file

Status
Not open for further replies.

jieyin

Programmer
May 22, 2003
9
0
0
US
I have a database regularly backed up in a .bak file. Over time this file grows larger and larger taking up a lot spaces. I want to trim it down a little bit by getting rid of some earlier versions of backup within the .bak file. Can I do that and how?

Thanks
 


How to trim .bak file
thread183-616491

first execute
restore headeronly from disk = 'path_name or backup_device_name'

Execiuting the above query will give you a table with column name "position"
Then check which position you want to take.And then execute the restore like the following

restore database dbname from disk = 'path_name' with file =
1 or 2 or 3 or 4 (depends which one you choose)
 
Claire,

Interesting post. Your solution won't work. jieyin doesn't want to RESTORE any of the data at this time. He/She wants to get rid of some of the backup data.

Jieyin,

Can't do it. It's all or nothing. Here's a possible solution:

Let's say you only want to keep one months worth of backups.
-You backup daily to mybackup.bak.
-After two weeks, you rename that file (ex. mybackupold.bak). Then you will have two backup files, mybackupold.bak and mybackup.bak will be recreated with the next backup job.
-After another two weeks, you delete mybackupold.bak and rename mybackup.bak to mybackupold.bak.

-SQLBill
 
Thanks, SQLBill. You got my point and I think your solution works fine for me. I will just periodically do this chore.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top