I want to run an image backup (using command line on windows) once a day. I want to keep one image for each of the last three days, so I have to rotate between 3 paths on each backup run, e.g.
c:\image0.ext // encode as 0, see text below
c:\image1.ext // encode as 1
c:\image2.ext // encode as 2
I though about writing 0, 1 or 2 in a text file, reading it’s value somehow, then do sth. like (number+1) mod 2, execute backup, write the new number to the text file. I would then link each number from 0 to 2 to a path using an if statement. Are there better/easier ways for that? Thanks for any hint!
Since imageX.ext is a file, I assume it is some compressed archive of your data analagous to a zip file. The modified date should get updated each time it is replaced with a new version, so you should not need a separate file to keep track of what is your most recent image. You can use DIR sorted by date to get the most recent image (last one listed).
This algorithm will break if someone creates another file that matches your file mask after your last image was taken.