Scott Hanselman

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

September 10, 2012 Comment on this post [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. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
September 10, 2012 6:28
Fantastic. Works like a charm. Now my email is in Gmail (cloud), local on my laptop, and then in Mozy (Cloud) again.
September 10, 2012 9:06
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/
September 10, 2012 11:42
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?
September 10, 2012 17:49
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!
September 10, 2012 18:50
I use MailStore instead, it is GUI based but can be scheduled just as easily.
September 11, 2012 0:31
I dont get it. Isn't google backing up gmail?
September 11, 2012 1:13
Wharf - This all presumes Google to never make a mistake, never lose a backup and never lock you out of your own mail.
September 11, 2012 2:44
350,000?

Thanks, Scott.

I feel so much better about myself now.
September 11, 2012 2:47
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.
September 11, 2012 11:29
Restore to any gmail account, Incremental backups and Built-In encryption? This is impressive... Kudos to @zoobert for that tool.
September 11, 2012 11:33
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!
September 11, 2012 11:34
Forgot the Synology link :/
September 11, 2012 20:24
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.
September 11, 2012 21:11
Does your IMAP go back 8 years? This can start from scratch and with the first email.

This backup is a complete one.
September 11, 2012 21:33
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!
September 14, 2012 14:00
Scott, do you know if gmvault works with proxy servers ?
Seems it doesn't
September 14, 2012 19:45
Maurizio - It's just IMAP so if you can get IMAP from your proxy, sure.
September 18, 2012 17:58
Thanks for the tip, I was just thinking about this not more than 2 days ago....sweet find.
September 24, 2012 5:48
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. :-)
November 12, 2012 13:19
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.
November 16, 2012 18:12
how do you restore it then? Is it a flat file (plain text)?
November 16, 2012 21:33
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".
November 18, 2012 20:21
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
November 20, 2012 20:37
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
December 30, 2012 1:24
Thanks for that Synology link, will set that up right away, since I got Crashplan running on it already :)
December 31, 2012 3:50
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.
February 01, 2013 14:14
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
March 05, 2013 9:24
Microsoft employee using Gmail instead of hotmail/outlook and proudly saying 'powered by Gmail'

nice work there.

you just lost respect from me.
March 05, 2013 22:48
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.
April 07, 2013 10:50
Very useful mailing tips. I always trying to get all my email backup, but often failure. This tips might help to do that.
June 24, 2013 13:57
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!
November 20, 2013 15:43
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!

Comments are closed.

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