Solved

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

Posted on 2004-09-28
3
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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