Solved

Compress and ship log files

Posted on 2011-09-26
9
459 Views
Last Modified: 2012-05-12
Servers are running SQL 2008 STD. I need to compress the log files created by LSBACKUP job and ship them over WAN to backup (standby) server, then extract them for LSRESTORE to do it's thing.  Standard LSCOPY job won't do the job because some of the trn files end up 20GB in size.  However, they zip or rar down to around 100mb, which would transport much better!  I need an automated solution, or a looping batch. Send server needs to only copy new files, and recipent end needs to ignore files already extracted.  I hope to be able to set up regular log shipping, and then just disable the lscopy job.  

Have looked at Unison file transfer, which supports compress before copy, but it could delete the recipient copy before lsrestore job applies it.  Is there a command line for winrar?  Need some ideas and inspiration here.
0
Comment
Question by:billherde
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Arman Khodabande
ID: 36707871
Hi
You can make a batch file with winrar command line options.
I attached the command line options. I know you can make something out of it. !
I'm busy these days . . .
rar-syntax.txt
0
 
LVL 3

Author Comment

by:billherde
ID: 36708178
I have the syntax for rar and unrar, what I am lacking is a part that will make a seperate file for each file found in the directory. It would be nice if they matched the filename being compressed, but that is not needed either.  I pretty much got the command line to compress and copy the file looking for archive bit and then reset archive bit on completion. Extraction and deleting the file at the destination works with if-then-else, but I don't know how to get a filelist into a table of variables and use it.
0
 
LVL 10

Accepted Solution

by:
Arman Khodabande earned 500 total points
ID: 36710341
Put the following script in a batch file and it adds files to separate archives. Just change the paths in script to be what you need on your system.
setlocal
set sourcepath=c:\<path to folder to backup>
set destpath=c:\<path to folder to store backups>
set wrpath=C:\Program Files\WinRAR
if NOT EXIST %destpath% md %_destpath%
for %%I in (%sourcepath%\*.*) do "%wrpath%\winrar" A "%destpath%\%%~nI.rar" "%%I"

Open in new window


Do your files in source path get deleted everyday or they're accumulative?
0
 
LVL 3

Author Comment

by:billherde
ID: 36710493
They are deleted by the maintenance job after 72 hours.  Thank You! that is the part I needed.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Author Closing Comment

by:billherde
ID: 36710504
Also found a canned program called Watchdirectory that does the job, but is limited to Zip compression.
0
 
LVL 10

Expert Comment

by:Arman Khodabande
ID: 36710806
Good to hear that.
But zip files may get corrupted during shipping!
Plus that you can compress the files further with Winrar by choosing high compression levels. (This makes the transfer faster too because of small files)
Good luck
0
 
LVL 3

Author Comment

by:billherde
ID: 36710907
Agreed.  That is why I am looking to scripting this using rar and unrar.  Initial testing found a 15gb tlog file compressed to around 1gb with winzip, but squeezed down to 125mb with winrar. My WAN link to the backup server is limited to 10mbps and offsite backup is out there as well. Watchdirectory has some desirable history logging, and will run as a service, but seems a bit much for a one trick solution.
0
 
LVL 10

Expert Comment

by:Arman Khodabande
ID: 36711128
Right.
Do you use -m5 switch to maximize the compression ratio? Use best compression method (slightly more compressive, but slowest) to reach the maximum file compression and reduced size.
0
 
LVL 3

Author Comment

by:billherde
ID: 36711578
Yes.  Makes a big difference for the small set!  After all, size does matter!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now