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.
| Author |
Topic |
|
pras2007
Posting Yak Master
216 Posts |
Posted - 2010-03-29 : 09:30:14
|
| Hello All,I got a script from the net and it is not working for me. The following is what it suppose to do:1. Backup the database2. Zip up the backup database using WinRar3. Delete the backup .bak fileEverything works except for number 2, does everyone what wrong? I have tried different variation of single quotes and double quotes around the path name.Below are the scriptsPlease help.--BACKUP BACKUP DATABASE [DARS] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\CARS_BACKUP.BAK' --COMPAC RAR DECLARE @SERVER VARCHAR(100), @COMMAND VARCHAR(100), @FILE VARCHAR(100) SET @SERVER = @@SERVERNAME SET @COMMAND = '"C:\Program Files\WinRAR\RAR.exe" A "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\CARS_BACKUP.BAK"'EXEC XP_CMDSHELL @COMMAND --EXECUTE FILE BACKUP EXEC XP_CMDSHELL 'DEL "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\CARS_BACKUP.BAK"' |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-03-29 : 12:42:52
|
use winrar, not rar. also need to specify destination archive file. and "program files" needs double quotes around it.i'd do this in a SQL Agent job with 3 steps:1. Execute backup -- T-SQL2. zip it -- os cmd3. delete bak file -- os cmdhere's a command file i use to zip up a bunch of txt files i generate with BCPdel dr.rarC:cd C:\"Program Files (x86)"\WinRAR|winrar a c:\xfer\dr c:\xfer\*.txt that red pipe is actually a backslah (\), but the forum software keeps messing with it |
 |
|
|
pras2007
Posting Yak Master
216 Posts |
Posted - 2010-03-29 : 16:25:47
|
| Thanks Russell for the response, your suggestion works but it is not zipping the back file in the correct location. Also I will try to zip up the backup files after maintenance job finish... Since I will need help with that particular task I posted another question.Thanks. |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-03-30 : 10:11:55
|
| winrar a c:\xfer\dr c:\xfer\*.txtwinrar a pathToArchiveFile locationOfFile(s)ToZip |
 |
|
|
|
|
|