Solved

Automating File Compression in as a scheduled task - (command line script)  --- Windows 2000

Posted on 2004-09-28
3
150 Views
Last Modified: 2010-04-13
I have a customized SQL database that does a nightly backup to a backup folder.

The file naming structure embeds the date and time into the file name.  Example: oasis_db_200409282000.bak

My backup database file size exceeds 4GB.

I am needing to compress this file so that I can manange it with my tape backup.

I have tried using gzip to compress the file.  This works great and reduces the file to 750MB.....perfect size.

My problem is I don't know how I can accomodate the changing file name.  gzip doesn't allow wildcards.

I am running Windows 2000 Server where my database is located.

Is there another way/method to accomodate this task?

Thanks.
0
Comment
Question by:j4piper
3 Comments
 
LVL 23

Expert Comment

by:rhandels
ID: 12177149
Hi,

You can set up compression on the folder where the .bak file is placed, to do so, right click on the designated folder, then on the general tab, choose Advanced. On the advanced tab, check the  "Compress data to free up space".. Don't really know how much it will safe ya..
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 12178566
Here's a VBScript that should handle this for you.  Here what you need to do to use it.

1.  Copy the script and paste it into a file whose name ends with .vbs.  I called the script ZipFile but you can rename it to anything you like.

2.  Edit the variable strBaseCommand and replace it with the correct command line for Gzip.  I don't use it so I don't know what it should be.  DO NOT change <%FILENAME%>.  It must remain in the command line as the name of the input file, the file to be zipped.  Change OutputFileName to the full path, including the file name, of the zip file Gzip is to produce.

3.  Edit the line that begins with Set objFolder and change the path to the path where the backup file is located at.

4.  Run the script.  It'll search the path you entered in step #3 and find all .bak files, I'm assuming there will only be one there, and run the Gzip command.  If my assumption is wrong, then the script will zip each .bak file it finds.  If that's a problem, then I can mod the script to stop after finding one.

---------- Script: ZipFile.Vbs
    Dim objFSO, objShell, objFolder, objFile, strBaseCommand, strCommandLine
    strBaseCommand = "Gzip <%FILENAME%> OutputFileName"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Wscript.Shell")
    Set objFolder = objFSO.GetFolder("C:\Testing")
    For Each objFile In objFolder.Files
        If LCase(objFSO.GetExtensionName(objFile.Name)) = "bak" Then
            strCommandLine = Replace(strBaseCommand, "<%FILENAME%>", objFile.Path, , , vbTextCompare)
            objShell.Run strCommandLine
        End If
    Next
    Set objFile = Nothing
    Set objFolder = Nothing
    Set objShell = Nothing
    Set objFSO = Nothing
0
 

Author Comment

by:j4piper
ID: 12178734
I will give this a try in the next day or two.  My actual data path is in d:\sql_backups.  The gzip command line goes like this;

gzip -c filename.bak > filename.gz

Thanks a million.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mystery using IF with Concatenate using MS Excel 10 659
Outlook 2013 Certicate error 1 286
VBScript not processed at Windows 8.1 logon 2 7,951
Install Window 2012 Domain on 9 125
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

21 Experts available now in Live!

Get 1:1 Help Now