| BradTrupp.com - Little slices of my life and my projects | BradTrupp.com -- Tags -- Code |
| ||
BradTrupp.com -- Tags -- Code -- A Little Bit of Automation for your Backups
A Little Bit of Automation for your Backups
There are likely thousands of ways to backup your computers data. One I like, since it is simple, is using a batch file that calls 7zip to create a zip backup with the current date embedded in the zip file name. This method can be described as "so 1980's" since it is done with batch or command files calling batch programs with command line parameters. You need working copies of Ruby and 7zip installed. Both products are open-source and free. The first piece of the puzzle is a short ruby script that does nothing more than create a one-line batch file to set an environment variable with a formatted date string for today.
Save this script as "set-yymmdd.rb". Run this script and you will get a new file "yymmdd.bat" that looks like this.
If you do not understand how environment variables work in Windows command processing, you can read up on in many web sources including these articles at Microsoft Support and Wikipedia Now the magic that pulls it all together is the final batch command script
In this case "c:\PersonalApps\*.*" is a directory on my computer that I want backed up. The backup is being written to a network drive that I have permanently mapped to my Q drive and it has an existing "\backups" subdirectory. The backup itself gets named "Personal 2010-02-25.zip" since I ran it on February 25th of 2010. The current date is a part of the file name so backups done on other days will have unique names and will not accidentally overwrite. In my case, I keep a folder on my desktop with icons to run the various backups when I want. You could just as easily set up any scheduler program, including Windows built-in ability to run scheduled tasks, to make your backups run automatically.
Tags: Code Share: Del.icio.us | Digg | Facebook | Google Bookmarks | Reddit | Technorati | Twitter | Windows Live | Yahoo! My Web
|
|