Solved

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

Posted on 2004-09-28
3
149 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

14 Experts available now in Live!

Get 1:1 Help Now