Technical Article

Script to Zip a Backup File

,

A handy dandy proc that can be used to zip up a backup file to location specified. Also called from a backup script to automate the compression of all backups using PKZip command line utility. Make sure pkzip is in the path and found by the shell prior to using this script.

USE MASTER

GO

SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON 

GO

create proc sp_dba_ZipFile @zippedfile varchar(50),@srcfile varchar(50)

/************************************************************** 

#Edward J Pochinski III 3/25/01 Modified: 

# Email: mcdba@sql-scripting.com 

# Usage: sp_dba_zipfile 'D:\backup\filename.zip','D:\backup\fileToZip.bak' 

# Procedure will zip a backup file to location with name specified
 ***************************************************************/ 

AS Declare @cmdstr varchar(8000) 

Set @cmdstr = 'pkzipc -add '+ @zippedfile +' ' + @srcfile

exec master..xp_cmdshell @cmdstr 

GO 

SET QUOTED_IDENTIFIER OFF SET ANSI_NULLS ON 

GO

Rate

1 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

1 (1)

You rated this post out of 5. Change rating