Deleting files from Network Folder/copy location
Giggles220
Posts: 154
I was really excited about this new feature but now I'm finding that it isn't working as advertised. I have my job set up to delete files older than 7 days in the original backup location and after 4 days in the network copy location. When I looked at my network copy location today I see it is still saving 7 days worth of backups. In the past I used other jobs to do the deletes and it looks like I'll have to go back to doing so as I don't have enough space sometimes to keep 7 days worth. is this a known bug or am I doing something wrong?
Comments
Can I just ask when you last ran a backup job? The purging of backups is a task which happens after the backup itself, so the files older than 4 days on your network location will only get deleted the next time it's run. Also it will only delete files for the databases which are being backed up in the job, so files for different databases will remain in the location.
If it is running a backup job for the databases which have backups in the remote location and they are not being deleted, could you send me the command you are using?
thanks,
Helen
SQL Backup Project Manager
Red Gate Software
The job runs every night so I'd expect it to do deletes every night.
Here is the code in the job. I created the job using the GUI and did not modify it outside the GUI at all.
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
This will be fixed in the next release of SQL Backup. Thanks for bringing this to our attention.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
By next release, do you mean it was fixed in 6.1, will be fixed in the next release of 6.x, or that I will have to manually purge my files since it won't be fixed until version 7.x?
Until then, you will have to manually purge encrypted version 3, 4, 5 files, until only version 6 files remain in the backup folders.
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Tim
SQL Backup version 6.3 has been released and should fix the problem.
Thanks for your patience.
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
DECLARE @sqlerrorcode int
EXECUTE master..sqlbackup '-SQL "BACKUP DATABASES [...] TO DISK = ''D:\Backups\SQLServer\<database>\<AUTO>.sqb'' WITH ERASEFILES = 4b, ERASEFILES_REMOTE = 3b, FILEOPTIONS = 1, MAILTO = ''...'', DISKRETRYINTERVAL = 30, DISKRETRYCOUNT = 10, COMPRESSION = 2, COPYTO = ''G:\Backups\SQLServer'', THREADCOUNT = 7"', @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
Note that I added the FILEOPTIONS directive manually. Previously it was not there, but that configuration did not work either.
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
ERASEFILES = 4b alone would have retained 4 backup sets in the primary backup folder (D:\Backups\SQLServer\<database>). By adding FILEOPTIONS = 1, SQL Backup will then also apply that retention policy to your COPYTO folder (G:\Backups\SQLServer).
Unfortunately, there isn't a way to do what you require now i.e. retain 4 backup sets in the primary backup folder, and 3 backup sets in the COPYTO folder.
The next release of SQL Backup will make all this much more straightforward, by adding a ERASEFILES_PRIMARY and ERASEFILES_SECONDARY options. So to do what you need, you can use
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
set @strsql =
'EXECUTE master..sqlbackup ''-SQL "BACKUP DATABASE test TO DISK = ''''\\share\temp\test.sqb'''' WITH ERASEFILES = 7, ERASEFILES_REMOTE = 7, FILEOPTIONS = 1, COPYTO = ''''\\machinename\d$\temp\'''', INIT, THREADCOUNT = 2"'', @exitcode OUT, @sqlerrorcode OUT'
EXECUTE sp_executesql @strsql, @ParmDefinition, @exitcode=@ecode OUTPUT, @sqlerrorcode=@secode OUTPUT ;
If this is a test machine, could you try running test backups over 8 days by manipulating the system time (you will need to use different file names, and not just 'test.sqb'), and send me the SQL Backup log for the backup that was suppose to delete the old files but did not do so? The default directory where the logs are stored is C:\Documents and Settings\All Users\Application Data\Red Gate\SQL Backup\Log\<instance name> on Windows 2003 and older, and C:\ProgramData\Red Gate\SQL Backup\Log\<instance name> on Windows Vista and newer.
Thanks.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
Here is last log of DelayCheck. It has been running over 2 weeks.
SQL Backup log file 6.4.0.56
-SQL "BACKUP DATABASE DelayCheck TO DISK = '\\<share>\DelayCheck\DelayCheck_backup_20101129021500.sqb' WITH ERASEFILES_REMOTE = 7, ERASEFILES = 7, FILEOPTIONS = 1, COPYTO = '\\<remotecomputername>\d$\SQLServer\Backups\DelayCheck\', INIT, THREADCOUNT = 7 "
PROCESSES COMPLETED SUCCESSFULLY
11/29/2010 2:15:00 AM: Backing up DelayCheck (full database) to:
11/29/2010 2:15:00 AM: \\<share>\DelayCheck\DelayCheck_backup_20101129021500.sqb
11/29/2010 2:15:01 AM: BACKUP DATABASE [DelayCheck] TO VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F', VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F01', VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F02', VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F03', VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F04', VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F05', VIRTUAL_DEVICE = 'SQLBACKUP_237CB09B-13F8-4D00-BAC7-9E861464D01F06' WITH BUFFERCOUNT = 28, BLOCKSIZE = 65536, MAXTRANSFERSIZE = 1048576, NAME = N'Database (DelayCheck), 11/29/2010 2:15:00 AM', DESCRIPTION = N'Backup on 11/29/2010 2:15:00 AM Server: <localcomputername> Database: DelayCheck', FORMAT
11/29/2010 2:15:31 AM: Database size : 8.849 GB
11/29/2010 2:15:31 AM: Compressed data size: 535.220 MB
11/29/2010 2:15:31 AM: Compression rate : 94.09%
11/29/2010 2:15:31 AM: Processed 241992 pages for database 'DelayCheck', file 'DelayCheck_Data' on file 1.
11/29/2010 2:15:31 AM: Processed 3 pages for database 'DelayCheck', file 'DelayCheck_Log' on file 1.
11/29/2010 2:15:31 AM: BACKUP DATABASE successfully processed 241995 pages in 30.114 seconds (65.830 MB/sec).
11/29/2010 2:16:04 AM: Copied \\<share>\DelayCheck\DelayCheck_backup_20101129021500.sqb to \\<remotecomputername>\d$\SQLServer\Backups\DelayCheck\DelayCheck_backup_20101129021500.sqb.
11/29/2010 2:16:04 AM: SQL Backup process ended.