Require a batch file to zip files and move to Different loacation

  • Hi All,

    Small help required. Need a batch file which does the below functionality.

    Step1: Zip files D:\SrcFiles

    Step2: place in different drive F:\Archive

    [Here\, the system should be able to create a folder with todays date F:\Archive\20100101 and place all the zip files

    Step3: delete the existing files

    I need this so that i can zip my sql server backups and move it to a different folder or any tape device or so....

    Thanks!

  • while you can do it from within SQL server with some TSQL commands, guess what....all the work goes out to xp_cmdshell to call programs like 7zip/winzip/pkzip, and then the MOVE or COPY function from the command prompt anyway....so why not do it from the OS as a bat or cmd file instead?

    for example, if you were going to use 7zip, you get the syntax of the command line to zip stuff up here:

    http://dotnetperls.com/7-zip-examples

    once the zip is made, the syntax of the COPY function can be retrieved from COPY /?; ie

    COPY "c:\backups\Full\Fulldevice.bak" "Y:\Monday.BAK or COPY "c:\backups\Full\Fulldevice.zip" "Y:\"

    with those commands tested and working, you can make a .cmd or .bat file, and eitehr call it with the Operating system's Scheduled Tasks, or via xp_cmdShell, if it is enabled, and also if the SQL server Service Account has access to the network share you want to move it to;

    I always think scheduled tasks are easier.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Just read this post yesterday on using SSIS to zip files. It is another cool and simple way to accomplish what you need. Check it out. Click here[/url]

  • Hey,

    Am using SQL 2000 and that is the reason why am going for a windows batch file.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply