Instructables

Roll your own version control/automated backup

Picture of Roll your own version control/automated backup
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...
 
Remove these adsRemove these ads by Signing Up
snthsnth4 months ago

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???

PKM (author)  snthsnth4 months ago

1) For the challenge
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)
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 :)
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

Don't get me wrong, on balance "proper" 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 "funny virus prank lol"

E_MAN4 years ago
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
sylvain01 E_MAN4 years ago
free backup http://www.educ.umu.se/~cobian/cobianbackup.htm
E_MAN E_MAN4 years ago
Never mind. I figured it out. dim filesys set filesys=CreateObject("Scripting.FileSystemObject") filesys.MoveFile "Backup.zip", "\\Server\Backups\" 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
fwjs285 years ago
wow! at first it seemed a little complicated, but its actually quite simple...im thinkging of using it for my little server project...
camintmier6 years ago
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.
PKM (author)  camintmier6 years ago
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.