Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using Windows Server 2003, Sql-Server 2005 and 7-zip for archiving.

Each day maintenance plan adds all DBs to backup and i need to archive those but just those files.

How do i create .bat or .vbs script which

  1. deletes previous archive
  2. adds only new (of this day) files to archive, while naming this archive 1sql_020810.7z (date)

I don't need help with 7-zip commands but with dos/vbs. I don't know how to get Current Date and Files of This Day to archive...

Thanks.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

in you sql server maintenance plan, you can delete the previous backup (however, it won't know anything about your archive)

for /f "tokens=*" %%I in (currentarc.txt) do call :prune %%I
goto :renbackup

:prune
del %1


:renbackup
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)

move d:\backup\dbbackup.bak c:\backup\dbbackup%date%.bak
echo dbbackup%date%.bak > currentarc.txt
7z .....  (do your 7zip stuff on the file)

the first part of this batch file deletes the past archive

the second part of the batch file renames the current backup from sql server to one that has a date and adds the file name to a file that you will need the next time. then you can do your compression with 7zip.

note that i didn't test this but the concept should work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.