Writing a software project on WIndows? Want access to all your old versions? Don't want to have to say "Oh man, I just lost a week's work" ever again? You need version control and automated backups.

A little background: I wrote this simple pair of scripts to save me time and effort at work. I am currently working on a software project that needs frequent rebuilding, so wrote my own custom build script. After the second or third time I accidentally overwrote my most recent changes and lost some small amount of work, I decided that I wanted to back up every time I built the thing.

Secondly, now that the project is being distributed and others are testing it, I get bug reports saying "I found this bug using the version from the 18th of August, can you reproduce it and fix it?". I need to be able to do that, so needed an easily accessible copy of the older versions of the project to recreate bugs on.

Having stored versions of your old code also makes fixing regressions (breaking things that you previously had working) a snap- you flick back through your old versions to find the point at which one version works and the one after it doesnt, find the differences between the two and your problem will be right there.

I decided to write this up
a) to share my work with people who might appreciate it
b) lest anyone suggest all I do is bitch about Instructables about batch files and never contribute any useful ones myself.

Please Note: I have licensed this as "all rights reserved" because it's possible that my employer owns the IP to this project, not me. As such I can't license it for modification and redistribution, so please don't redistribute this code. If you want to point people in the direction of the Instructable, however...

Step 1: You Will Need

- A command line zip program. I use 7zip because it's free and easy to use from the command line.

- Windows. I am aiming this at WIndows because that's what I have the code for, and I'm sure there are plenty of scripts like this one for Linux already. The idea would work just as well in Linux but you'd probably have to translate the batch file and VB Script so it's hardly worth the bother.

- Hard disk space. This isn't an incremental backup, it's a naive save-the-whole-lot-every-time backup. Hard disk space is cheap, but if your project is very large or you want to back up twenty times a day for a whole academic year then you might have some hard disk space issues. Worst comes to worst, buy a spindle of CD-Rs and shift your backups onto one of those when you hit 600mb or so.
<p>Really? Why not just use CVS, SVN, Git, Bzr, Hg, or any of the wide variety of free and widely used and tested version control systems already in existence???</p>
<p>1) For the challenge<br>2) Because as a professional wheel-reinventer, writing these batch scripts was simpler than setting up a SVN repo (and at the time my work used CVS leading me to believe that all professional source control was a horrible nightmare of complexity)<br>3) Because it was easy to tie in with the custom build script I wrote for my project that would build it and backup in a single scriptable action, so I could run the script and go make a cup of tea while it built and backed up :)<br>4) Because in my case, each backup was only a couple of megs so I didn't care about disk space, but I did need frequent access to old versions and didn't want to have to check it out of source control every time</p><p>Don't get me wrong, on balance &quot;proper&quot; source control is better for large or multi-user projects- this was also an exercise in useful batch scripting in response to the stuff I was seeing at the time, which was mostly &quot;funny virus prank lol&quot;</p>
Nice Instructable!! How could I modify this to back up to a network server? Batch files do not UNC paths. I would be backing up to \\Server\Backups\ if that helps at all. Thanks so much. Happy instructabling. :D
free backup http://www.educ.umu.se/~cobian/cobianbackup.htm
Never mind. I figured it out. dim filesys set filesys=CreateObject(&quot;Scripting.FileSystemObject&quot;) filesys.MoveFile &quot;Backup.zip&quot;, &quot;\\Server\Backups\&quot; It just moves a file called Backup.zip to \\Server\Backups\ Add it before the rest of the script in snapshot.vbs, and change the path in the existing code to be \\Server\Backups\ Happy instructabling. :D
wow! at first it seemed a little complicated, but its actually quite simple...im thinkging of using it for my little server project...
Instead of going Day - Month - Year, you might want to go Year - Month - Day. YMD tends to sort better than DMY. Otherwise it looks fairly decent.
Very good point- I'd totally forgotten about the sorting. I just used Date as it comes out of VBScript to avoid any more messing around with string functions, but that would be a good addition.

About This Instructable



More by PKM:Dining Chair From a 2x4 Word art trivet Sugru lens cap saver 
Add instructable to: