Solved Increment backup filename by 1 each day

March 6, 2013 at 08:06:26
Specs: Server 2008 R2
I have been poking around various posts but cannot find a solution that fits.

I backup a Progress database daily, saving all previous versions by incrementing the extension by 1; live.bk001, live.bk002, etc.
I would like to automate this process in a batch file, incrementing the next backup by 1 from the previous backup; then move the old file from C:\backup to an archive folder C:\oldbackup.
The numbering doesn’t matter as long as each new file is incremented by 1 somewhere. It could be in the extension or the file name, and could even use year/month/day incrementing (which would be great!).
File names with just the date would work too, i.e. 20130215.bk and 20130216.bk for backups dated February 15 and 16 of this year.
The actual backup command works fine from a batch:
“probkup.bat online H:\db\mfgsys C:\backup\live.bk065”

Thanks in advance

See More: Increment backup filename by 1 each day

Report •

March 6, 2013 at 09:19:00
✔ Best Answer
If it allows (and you are using the semi unstandardized date format of dow mmddyyy) you could try adding the variable %date:~0,3%

“probkup.bat online H:\db\mfgsys C:\backup\%date:~0,3%.bk”

note that a test would be recomended, as if the the program accepts it will probably rename to ddmmyyy, or whatever the date variable returns with the first four charactors removed. dates can be funny.

:: mike

Report •

March 6, 2013 at 09:45:35
I tried backing up to the file \%date:~0,3%.bk. It created the file "Wed.bk".
Best would be to get month, day and year; month and day would suffice as I manually weed out last months backups.

This is on a 2008 R2 server. When I enter DATE at the command prompt I get: The current date is: Wed 03/06/2013.

Report •

March 6, 2013 at 10:33:43
I finally found a note on how the DATE variable works:

the substring arguments are

So I modified the file name in the batch to:

and it created the file:

Just what I was looking for!
Thanks so much for your help.

Report •

Related Solutions

March 6, 2013 at 10:46:55
sorry I have been trying to post a simaler response, however was too slow. don't forget to mark your own response as the best answer. Glad you were able to figure it out.

:: mike

Report •

Ask Question