This image was lost some time after publication, but you can still view it here

by Gina Trapani

When my sister-in-law asked me how she could back up her master's thesis without any special equipment or software, I had to think for a second.


"Email it to yourself," I finally told her.

Emailing yourself important documents that change often is a quick and dirty - yet very effective - form of backup, especially if you're using a web-based email solution like Gmail or Yahoo! Mail. By regularly emailing herself a copy of the Word document she'd been slaving over for months, my sis would be storing it somewhere off-site (in case of drive failure, theft, fire or flood) and she'd also build up a directory of document versions over time, all in her inbox.

Even with my fancy-pants automated backup system, every once in awhile I get to emailing myself documents that I'm changing rapidly throughout the course of a day. You know, just in case.


For those of us who don't want to go through the motions of attaching a document to a new email and sending manually, I've got a Windows script that will do it for you. Schedule this script daily or hourly, or however often you need for quick and easy, versioned, off-site backup.

Note: This script requires a bit of command line work, .txt files and batch scripting. That sounds scary, but really, it's not.

Here's how to get your auto-emailer set up.

Download the main act in this emailing show, a small, free utility called Blat. Blat emails text and attachments from the command line. Unzip Blat into your C:\Blat250\ directory. Using Notepad or your text editor of choice, make a list of all the files you want to email yourself, separated by commas. Save that file as C:\Blat250\full\files-to-backup.txt. A sample files-to-backup.txt might look like:

d:\data\Important Document01.doc, d:\data\Career-changing Opus.ppt



But without the line break. List as many files as you'd like - just make sure there are commas between them. Install your SMTP server and set your From: email address. From the Windows command line (Start, Run, cmd), switch to the Blat directory, like so:






This image was lost some time after publication, but you can still view it here





Then run the following command, substituting smtp.yourserver.com with your SMTP server and you@youremail.com with your address:



Blat -install smtp.yourserver.com you@youremail.com





Without the line break. This tells Blat how to send the message and from whom.

Now, create your auto-email backup script. Copy and paste the following into a new text document:

c: cd \ cd Blat250\full\ Blat -body "Just in case." -s "[backup] Important files" -to you@youremail.com -af files-to-backup.txt That last command should not have line breaks in it. IMPORTANT: Change the you@youremail.com email address to the email address where you will store your backups. Do it now! Or else you will send sensitive information to a complete stranger. This cannot be undone. Finally, save this new file as C:\Blat250\full\email-file-backups.bat. (Make sure this is a .bat file, not a .txt file.)


And that's that! You're ready to test your new script. In Explorer, browse to the C:\Blat250\full\ directory. Double-click on your new script, email-file-backups.bat. A command window will pop up, with Blat doing it's thing. Within a few seconds, all the files you listed in files-to-backup.txt should magically appear in your inbox.

This image was lost some time after publication, but you can still view it here


Why do this instead of just save to a thumb drive or burn a CD?

The key here is that the files become available from anywhere you can get your mail. In the case of web-based mail like Gmail, that's anywhere you can get your paws on a web browser. If your laptop is stolen, thumb drive is lost, CD goes bad - you've still got your files up in the cloud. This works especially well for work files you've edited at home.


Filtering

You'll notice that the subject line of your email is "[backup] Important files" (that's set by the -s switch in your .bat file.) Use message filters and that [backup] in the subject line to fritter these messages out of your inbox and into a "backups" folder automatically, so they don't get in your way.


Scheduling

The neat thing about this script is that you can use Windows Task Scheduler to set it to run at certain times of day. Once a day could work. I've been working on a huge client project every day for months now, and I've got a spare Gmail account with lots of space, so while those documents are undergoing massive changes, I have the script run every 20 minutes. See more on using Windows Task Scheduler.


Warnings

I haven't tested this out with very large files, but keep in mind that some SMTP servers may limit the size and number of attachments you can send at a time. Also, if you're a Gmail user, keep in mind that .exe file attachments don't make it through Gmail's spam filters. Basically this method isn't for backing up more than just a handful of smallish files, like Office documents.


Troubleshooting

If your script doesn't work, from the command line cd to c:\Blat250\full\. Then run the command from there (just type email-file-backups.bat) and watch the output. If there's a problem connecting to your SMTP server, it'll be listed there. There are tons of switches and options for Blat - if you need to specify a non-default mail port, or username and password to log onto your SMTP server, for instance. Run Blat -h to see the full rundown. Also, the Blat Yahoo! Group is active and the archives contain a lot of great troubleshooting information.


Mac OS X users

You Mac peeps don't even need Blat to get this done. You've got a program called mail all built into OS X and available for use at the Terminal, so this is even easier for you, ya lucky, shiny things.


If you're looking for a more, ahem, comprehensive backup plan, check out my previous feature, Automatically back up your hard drive.

In the meantime, enjoy your email backups!

Gina Trapani, the editor of Lifehacker, thinks redundancy is a very good thing. Her semi-weekly feature, Geek to Live, appears every Wednesday and Friday on Lifehacker. Subscribe to the Geek to Live feed to get new installments in your newsreader.