Red Gate forums :: View topic - Redgate Backup - Won't Delete All Files Before Backing Up
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Backup 7
SQL Backup 7 forum

Redgate Backup - Won't Delete All Files Before Backing Up

Search in SQL Backup 7 forum
Post new topic   Reply to topic
Jump to:  
Author Message
JoshDBGuy



Joined: 04 Jan 2013
Posts: 8

PostPosted: Mon Feb 18, 2013 8:24 pm    Post subject: Redgate Backup - Won't Delete All Files Before Backing Up Reply with quote

I am running backups to a location with limited storage. Because these backups aren't exactly critical, I only need one backup file. I am setting the program to run and delete existing backup files except for the latest "1" and also with "delete prior to start of backup" enabled. However, when I run this, it keeps the last backup and causing space issues on the drive. How can I change the program to delete all backup files before the program runs? Can i change the step in the job within sql and set it to 0b instead of 1b?

Thanks
Back to top
View user's profile Send private message
epetro



Joined: 31 May 2011
Posts: 55
Location: Zotec Partners

PostPosted: Mon Feb 18, 2013 8:56 pm    Post subject: provide code Reply with quote

I think you will get more assistance if you provide the code you are currently running.
You can adjust database/server names for confidentiality.

I know we had an issue with this some time back, but in recent versions no problems.

Be sure to pay attention to any TAPE backup that may be picking up(locking) the previously created file.
You should be able to rename the file as a test to see if it is locked.
Back to top
View user's profile Send private message
JoshDBGuy



Joined: 04 Jan 2013
Posts: 8

PostPosted: Mon Feb 18, 2013 10:46 pm    Post subject: Reply with quote

Sure, below is the code,

DECLARE @exitcode int
DECLARE @sqlerrorcode int
EXECUTE master..sqlbackup '-SQL "BACKUP DATABASES [DB1,DB2,DB3] TO DISK = ''C:\Backup\Full\<database>\<AUTO>.sqb'' WITH ERASEFILES_ATSTART = 1b, PASSWORD = ''<ENCRYPTEDPASSWORD>xxxxxxxxxxx</ENCRYPTEDPASSWORD>'', CHECKSUM, DISKRETRYINTERVAL = 30, DISKRETRYCOUNT = 10, KEYSIZE = 256, THREADCOUNT = 23"', @exitcode OUT, @sqlerrorcode OUT
IF (@exitcode >= 500) OR (@sqlerrorcode <> 0)
BEGIN
RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)
END




I also double checked and no tape backups are running or did run at the same time.
Back to top
View user's profile Send private message
epetro



Joined: 31 May 2011
Posts: 55
Location: Zotec Partners

PostPosted: Tue Feb 19, 2013 4:30 pm    Post subject: erasefiles_atstart values Reply with quote

We use the erasefiles_atstart option with a value of 40h.
This assumes we are running a daily backup (every 24 hours) and wish to always have at least 1 complete backup available on disk.

If you wish to essentially overwrite the previous backup you can simply set this value to less than your expected backup schedule.

So if you are running a daily backup, try
Code:
erasefiles_atstart = 1h
Back to top
View user's profile Send private message
JoshDBGuy



Joined: 04 Jan 2013
Posts: 8

PostPosted: Tue Feb 19, 2013 5:19 pm    Post subject: Reply with quote

Thanks epetro, I thought of something like that too. It's not super clean but it should work for our office.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group