Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Zip backupfile from maintenance

Author  Topic 

bharath63
Starting Member

14 Posts

Posted - 2009-01-08 : 17:30:15
Hi,

We have maintenance plans for taking backup of the database and files older than X days are deleted. But the backup job fails on regular interval due to diskspace and I need to make space manually and I know its not a good practise finding a temproary solution. So is there anyway I can Zip the backup file in Sql server 2000?

Like can I add any extra command to the Plan which will zip the backup.

BHARATH

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-08 : 17:50:37
Yes you can zip them up. We use PKZip and WinRAR to do it. Both of them have a command line version of their application.

I don't know if you can add it to the plan, but you can certainly add it as another step in the job.

You should also consider compressing the backup rather than the file. We currently use SQL Litespeed and will be using Red Gate's solution soon too.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

bharath63
Starting Member

14 Posts

Posted - 2009-01-08 : 17:58:01
ok will try adding another step to the job for ziping but another question arises will the plan delete those file as per the paln. And Can you please elaborate on how to add that another step.

And currently we do not use any third party tool.

BHARATH
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-08 : 18:24:32
The plan will not manage the zipped files for you.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

bharath63
Starting Member

14 Posts

Posted - 2009-01-08 : 18:54:16
Anyother option?? I guess this must be a common problem.. I have idea of writing stored proc for deleting this files but servers are also many. but do not know the best solution as I was a developer dba before..

BHARATH
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-08 : 18:57:39
You can grab the delete code from my backup stored procedure: http://weblogs.sqlteam.com/tarad/archive/2008/08/19/Backup-SQL-Server-Databases.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-08 : 18:59:22
I haven't used this in a while, but I've also got a stored procedure specifically to delete files outside of my normal backup routine:

CREATE PROC [dbo].[isp_Backup_Delete]
AS
SET NOCOUNT ON

DECLARE @now datetime, @rowCnt int, @bkpRetention int, @i int
DECLARE @bkpLocation varchar(512), @cmd nvarchar(4000), @file varchar(256)

SELECT @now = GETDATE(), @i = 1

SELECT IDENTITY(int, 1, 1) AS dbInfoID, BackupRetention, BackupLocation
INTO #dbInfo
FROM DatabaseInfo
WHERE ServerName = @@SERVERNAME
ORDER BY DatabaseName

SET @i = @@ROWCOUNT

CREATE TABLE #Dir(DirInfo VARCHAR(7000))

WHILE @i <> 0
BEGIN
SELECT @bkpRetention = BackupRetention, @bkpLocation = BackupLocation
FROM #dbInfo
WHERE dbInfoID = @i

SET @cmd = 'dir ' + @bkpLocation + ' /OD'

IF RIGHT(@bkpLocation, 1) <> '\'
SET @bkpLocation = @bkpLocation + '\'

INSERT INTO #Dir
EXEC master.dbo.xp_cmdshell @cmd

DELETE
FROM #Dir
WHERE ISDATE(SUBSTRING(DirInfo, 1, 10)) = 0 OR DirInfo LIKE '%<DIR>%' OR SUBSTRING(DirInfo, 1, 10) >= GETDATE() - @bkpRetention

SELECT TOP 1 @file = SUBSTRING(DirInfo, LEN(DirInfo) - PATINDEX('% %', REVERSE(DirInfo)) + 2, LEN(DirInfo))
FROM #Dir

SET @rowCnt = @@ROWCOUNT

WHILE @rowCnt <> 0
BEGIN
SET @cmd = 'del ' + @bkpLocation + @file + ' /Q /F'

EXEC master.dbo.xp_cmdshell @cmd, NO_OUTPUT

DELETE
FROM #Dir
WHERE SUBSTRING(DirInfo, LEN(DirInfo) - PATINDEX('% %', REVERSE(DirInfo)) + 2, LEN(DirInfo)) = @file

SELECT TOP 1 @file = SUBSTRING(DirInfo, LEN(DirInfo) - PATINDEX('% %', REVERSE(DirInfo)) + 2, LEN(DirInfo))
FROM #Dir

SET @RowCnt = @@ROWCOUNT
END

DELETE FROM #Dir

SET @i = @i - 1
END


DROP TABLE #dbInfo, #Dir



Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

bharath63
Starting Member

14 Posts

Posted - 2009-01-09 : 16:59:36
Thank you Tara.. will work around it and will first notify u thru mail if it worked :).

BHARATH
Go to Top of Page

bharath63
Starting Member

14 Posts

Posted - 2009-01-09 : 17:00:28
Thank you Tara.. will work around it and will first notify u thru mail if it worked :).

BHARATH
Go to Top of Page
   

- Advertisement -