April 9, 2013 at 8:17 am
Hi All,
I am trying to use to compress some backup files with the 7zip program.
I am able to compress the files via the command prompt by doing the following
1. I first of all change the directory by entering ...
cd\program files\7zip
2. I press enter
3 then I enter the following command...
7z a -t7z C:\offers\datafile.7z "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\*" -p"withoutytreedd" -mhe -r -y
This compresses the files and add them to datafile.7z
However when I save
7z a -t7z C:\offers\datafile.7z "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\*" -p"withoutytreedd" -mhe -r -y
to a batch file (.bat), it doesn't work.
My question is 'How do I change the directory within the same batch file so that I can schedule it via windows scheduler?
I need the batch file to
1. change the directory
2. compress the files and add it to the zip file (datafile.7z)
Thanks for your help
April 9, 2013 at 8:28 am
First, I have a question. Why arent you using SQL Server Compression when backing up? This generally reduces the backup file size down to less than 20% of what it was.
As far as running 7z in .bat I just use the full path in executing the 7z. So yours would look something like....
>"c:\program files\7zip\7z.exe" a -t7z C:\offers\datafile.7z "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\*" -p"withoutytreedd" -mhe -r -y
John
April 9, 2013 at 8:47 am
Thanks john for your reply.
I am compressing the .bak files using sql server.
I was trying to add all the compressed .bak files to one zipped location and then copy it somewhere elase.
I just couldn't figure out how to get the .bat file to change the directory once it opened the cmd prompt.
I will try your method and will get back to you.
Cheers
Yadhar
April 9, 2013 at 11:50 am
Oh. Ok. This should work for you. Works for me. Let me know.
April 11, 2013 at 2:52 am
Hi John,
Thank you for your reply.
It worked!
Adding "c:\program files\7-zip\7z.exe" to the .bat file changed the directory.
Thanks once again
Yarhad
April 11, 2013 at 7:32 am
Sure. Glad it helped.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply