Scott Hanselman

Automatically Backup your Gmail account on a schedule with GMVault and Windows Task Scheduler

September 10, '12 Comments [32] Posted in Tools
Sponsored By

It's nice to have your things backed up to the cloud, but you really need to have local backups as well. I have two 1TB pocket hard drives that I rotate between my home and the bank. They are labeled Offsite Backup A and Offsite Backup B. You can encrypt them with either Bitlocker To Go or TrueCrypt, and I do.

Related Links

I've got years and years of email in my only personal email account, powered by Gmail. I've recently started backing up my WHOLE gmail account with a wonderful free tool called GMVault. Setup requires a little attention to detail but once it's done, it's done.

Once installed, you run GMVault-Shell and type "gmvault sync youremail@address.com." The first backup will take HOURS and on Windows will put thousands and thousands of files in your C:\Users\YOURNAME\gmvault-db directory. You can move this directory if you want. My email backup was over 350,000 emails so I moved it to my larger D drive by using the -d option on the command line.

After this multi-hour sync was finally done, I wanted to make sure I updated the archive every week or so with backups of new emails.

Create a Scheduled Gmail Backup with Task Scheduler

Go to your start menu and type "Task" and run the Task Scheduler. Some folks don't even know this exists!

On the right side click "Create Basic Task."

Create Basic Task Wizard - Task Name

Make it weekly or monthly or whatever makes you happy.

Create Basic Task Wizard - Setting time

Your action is Start a Program

Create Basic Task Wizard - Start a program

Make the Program like this and check your path first.

"C:\Users\YOURNAME\AppData\Local\gmvault\gmvault.bat"

Under Arguments, use sync -t quick like this. Be sure to use the -t quick or you'll get ALL your email again!

sync -t quick youremail@address.com 

optionally you can point to a specific backup directory like this. If there is a space in your path, use quotes around it.

sync -t quick youremail@address.com -d D:\gmvault-db

I also made my task start in the same directory as GmVault, so "C:\Users\YOURNAME\AppData\Local\gmvault"

Create a Basic Task - final screen with all options set

My scheduled task ended up with command line arguments like this:

sync -t quick scott@myemail.com -d D:\gmvault-db

You can test it by right clicking on it in the Task Scheduler list and clicking "Run." If you need to debug it or if it just starts and then quickly disappears, go into your gmvault.bat and add a "pause" command before the "exit" command to keep the window open long enough to see any errors.

Here's my automatic Gmail backup in action:

GMVault automatically backing up my email

Hope this helps you!


This week's sponsor: Be part of GENERATION APP. Your Idea. Your App. 30 Days. Begin your 30-day journey to create a Windows Store style app and talk 1-on-1 with a Windows 8 app development pro. Get started today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Monday, September 10, 2012 2:28:13 AM UTC
Fantastic. Works like a charm. Now my email is in Gmail (cloud), local on my laptop, and then in Mozy (Cloud) again.
Monday, September 10, 2012 5:06:08 AM UTC
And if you have multiple email accounts (with IMAP access) and you want to keep them in sync, you can use larch: https://github.com/rgrove/larch/
Palesz
Monday, September 10, 2012 7:42:32 AM UTC
What if....your harddrive was the computer?
What if you glued a Raspberry Pi to the harddrive and got that to do the syncing.
What if you had 2 harddrives and 2 Raspberry Pi's?
RichB
Monday, September 10, 2012 1:49:31 PM UTC
Thanks! I used to use Gmail-backup, but it had some bugs I needed to work around, and as it was closed-source, I couldn't fix them. Can't want to give this a try!
Monday, September 10, 2012 2:50:32 PM UTC
I use MailStore instead, it is GUI based but can be scheduled just as easily.
Monday, September 10, 2012 8:31:38 PM UTC
I dont get it. Isn't google backing up gmail?
Wharf
Monday, September 10, 2012 9:13:19 PM UTC
Wharf - This all presumes Google to never make a mistake, never lose a backup and never lock you out of your own mail.
Monday, September 10, 2012 10:44:08 PM UTC
350,000?

Thanks, Scott.

I feel so much better about myself now.
Monday, September 10, 2012 10:47:40 PM UTC
Speaking of "locked out of my own email"...

Be very careful about trying to change your Live ID email address. I started, then changed my mind (since it offered me the chance) and I've been locked out of my Skydrive, Mesh, Live Messenger, Windows Phone 7 updates, MSDN and just about everything else I've ever logged into using my Passport/Live ID.

They are working on it - I hope - but I can't get in on the new username and can't on the old one. Both say they don't exist.

2,000 plus photos. Ugh.
Tuesday, September 11, 2012 7:29:56 AM UTC
Restore to any gmail account, Incremental backups and Built-In encryption? This is impressive... Kudos to @zoobert for that tool.
Tuesday, September 11, 2012 7:33:34 AM UTC
And it gets even better... you may install it on a Synology volume and have a true automatic solution, even when you power off your workstation.

With CrashPlan headless running on the same Synology server this is going to be a real piece of mind. Thanks Scott for sharing it!
Tuesday, September 11, 2012 7:34:13 AM UTC
Forgot the Synology link :/
Tuesday, September 11, 2012 4:24:26 PM UTC
This seems like a neat way to do it. I have been making the assumption that when I open Microsoft Outlook and sync my mailbox with IMAP every week or so I am making a backup. Then that .pst file goes into the CrashPlan folder and is put on the cloud.

I would assume I could do the same thing with Thunderbird or any email client. While clearly Scott's way is more consistent and superior in its hands off approach, am I missing something fundamental with using a mail client?

Am I making a backup with my plan?

Thanks for all the helpful posts.
Tuesday, September 11, 2012 5:11:17 PM UTC
Does your IMAP go back 8 years? This can start from scratch and with the first email.

This backup is a complete one.
Tuesday, September 11, 2012 5:33:19 PM UTC
Ah ha! I see the difference now. I honestly always assumed IMAP went back in time far enough, but clearly making assumptions with backups is pretty risky.

Thanks!
Friday, September 14, 2012 10:00:08 AM UTC
Scott, do you know if gmvault works with proxy servers ?
Seems it doesn't
Friday, September 14, 2012 3:45:09 PM UTC
Maurizio - It's just IMAP so if you can get IMAP from your proxy, sure.
Tuesday, September 18, 2012 1:58:28 PM UTC
Thanks for the tip, I was just thinking about this not more than 2 days ago....sweet find.
Hank Lynch
Monday, September 24, 2012 1:48:28 AM UTC
Was getting an Access is denied error trying to do this from Windows Home Server SP2. I performed both of the solution methods described here http://support.microsoft.com/kb/867466 but the issue was probably due to my failing to escape quotes properly or something related to not knowing how to really manage Server 2003.

I ended up putting the full command (with parameters) inside another .bat file and ran that (no parameters) from a scheduled task without issue. Hey, it works. :-p

Thanks for the heads up Scott, and mega thanks to @zoobert for this fantastic utility. Let's definitely support his effort! My wife's and my GMail accounts are backed up every night now. So cool. :-)
Monday, November 12, 2012 9:19:46 AM UTC
Another alternative is to try Dropmyemail's email backup solution. It provides simple and easy cloud based automated email backup.

Backups are taken on a daily basis for the pro account.
Friday, November 16, 2012 2:12:41 PM UTC
how do you restore it then? Is it a flat file (plain text)?
raoulsson
Friday, November 16, 2012 5:33:41 PM UTC
Raoulsson, the e-mails are backed up as .eml.gz files (Gzipped e-mail files - can be opened in your favourite client, it need be). There is also a "sidecar" .meta file for each message which contains Gmail specific info, like the labels and so on that it belongs to. All messages are stored in folders named with the scheme "yyyy-mm".
Philip
Sunday, November 18, 2012 4:21:21 PM UTC
Helpful hint: don't put quotation marks around the "start-in" folder or the task won't run. See http://www.arcomit.co.uk/support/kb.aspx?kbid=000058
Jason Freeman
Tuesday, November 20, 2012 4:37:51 PM UTC
Setup GMVault yesterday and this post really helped. Thanks!

One thing I like to do with automated scripts is to create a simple log file. This way if I notice something is awry I have an idea of what happened.

In this case I just piped (>) the output to a text file in the same destination folder. Using your example:

sync -t quick scott@myemail.com -d D:\gmvault-db > D:\gmvault-db\log.txt

Another thing I noticed is that Windows Search can't search inside gzip files, so I turned compression off to give myself the ability to do so. My backup wasn't much bigger with it turned off, and I like having the option (although I doubt I'll ever use it).
JJ
Saturday, December 29, 2012 9:24:40 PM UTC
Thanks for that Synology link, will set that up right away, since I got Crashplan running on it already :)
Sunday, December 30, 2012 11:50:21 PM UTC
Scott, Thanks for the post. I have this set up now and Crash Plan. All my data is secure now. Now to test the backups.
Friday, February 01, 2013 10:14:03 AM UTC
Hi, great post, but does this solution backup your calendar and contacts - or is it just email?

If, as I suspect, it is email only, it's useless for me I'm afraid - I don't want multiple solutions for a backup process: This way lies extra maintenance & configuration and testing (you do test your backups, right?)

As a result the greater complexity = less 'security' and more chance something will fail.

Just my thoughts,

Tim.
Tim
Tuesday, March 05, 2013 5:24:32 AM UTC
Microsoft employee using Gmail instead of hotmail/outlook and proudly saying 'powered by Gmail'

nice work there.

you just lost respect from me.
Sam Port
Tuesday, March 05, 2013 6:48:11 PM UTC
Sam Port - Seriously? Um. OK. I also have an iPhone. Turns out that Microsoft employees aren't a monolith and don't think every product we create is amazing. Now I'm going to go use my PlayStation.
Sunday, April 07, 2013 6:50:06 AM UTC
Very useful mailing tips. I always trying to get all my email backup, but often failure. This tips might help to do that.
Monday, June 24, 2013 9:57:35 AM UTC
Great post Scott

Sam Port...really are you being serious which decade are living in?

If us readers want something a little simpler to set up there is another option called GeeBak, its paid for but cheap, it does incremental backups and sits in the tray backing up to a schedule (every hour or so).

www.starbanana.com/Products/Gmail-Backup

Im posting cos I got caught out using thunderbird, it SYNCs your emails as oppose to Incremental backups which effectively deletes your local PC emails to match your online emails! Doh!
Tino Mclaren
Wednesday, November 20, 2013 11:43:38 AM UTC
Tiny tip for those of you who want to run the task minified in Scheduler;

Settings
Program/script:
cmd.exe
Add arguments:
/c start /min c:\path_to\gmvault.bat sync -t quick someone@gmail.com -d C:\path_to\Database ^& exit


Running this since a **long* time, saved my butt a number of times...

Thanks a bunch Scott!
Peter Rombouts
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.