Solved

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XP pro; manually run services in registry? 15 28
How to migrate DHCP sever on Windows 2003  to Windows 2008 4 515
Group Policy 9 561
VMware converter for windows 2000 server SP4 4 6,214
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…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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