How To Automatically Back Up And Purge Your Gmail Every 30 Days

How to Automatically Back Up and Purge Your Gmail Every 30 Days

If the Sony hack has taught us anything, it's that keeping incriminating emails in your inbox is a terrible idea. If someone gets into your email, everything you've ever said could be out in the open. Here's how to make sure that doesn't happen by automatically backing up and deleting everything in your Gmail account on a schedule.

How to Automatically Clear Out 30-Day-Old Messages

How to Automatically Back Up and Purge Your Gmail Every 30 Days

If you want to clear out your Gmail every so often, you'll need a Google Script. We're going to use this one from Digital Inspiration. You can do this with a lot of email clients, but we're going to focus on Gmail. If you'd prefer, here are guides for Outlook and Thunderbird. Google Apps owners can also just change the retention period for emails. That said, here's how to set it up on regular old freebie Gmail account:

  1. Click here to make a copy of the Google Auto-Purge Script
  2. The script deletes emails based on label, so you'll need to enter the labels you want here. For a catch-all, use "Inbox", for the var GMAIL_LABEL = " "; line. Unfortunately, you'll need to do this for each label, but it will also pull messages you've archived.
  3. Enter in the number of days you want to schedule the purging for under var PURGE_AFTER = "1"; for our purposes we chose 30. Any message older than 30 days old gets sent to the trash
  4. Click Run > Initialize and follow the prompts to add permissions
  5. Click Run > Install to install the script.

Now, your Gmail account will clear out any message older than 30 days. If your Gmail account is filled to the brim with email, you might want to go through and delete everything manually at first. It's worth noting that this moves your messages to Gmail's trash, which takes 30 more days to completely delete. If you're worried about that, set a reminder to pop into your trash and manually delete everything.

How to Back Up and Encrypt Your Gmail Account on a Schedule

How to Automatically Back Up and Purge Your Gmail Every 30 Days

Deleting your email is pretty easy, but you can't search through old emails once it's gone. That sucks. So, you might consider making an encrypted, local backup of your email. This way, you can search through it when you need to, but your emails won't be stored on anyone's servers, ripe for hackers.

You have a lot of options for this (including some if you're not using Gmail), but we're going to use the open source software GMVault to download a backup of the Gmail account.

  1. Download and install GMVault for your operating system
  2. Open the app, you'll get a command line interface
  3. Head back to GMVault and type in gmvault sync -e [email protected] replacing [email protected] with your email address
  4. You'll be asked to log in and allow GMVault access to your account in your default browser. Click "Allow Access"
  5. Head back to GMVault and press Enter. It will back up all of your email and encrypt it (your encryption key is saved on your hard drive under /users/name/gmvault-db/.info/.storage_key.sec). It takes a while, so let it do its thing.

That's your first backup and it will probably take a while before it's finished up. Restoring your email depends on how you want to view them. GMVault has a guide for various restore options depending on when you want. Once the GMVault backup is done, you'll want to set up a system to back up your email once a week. How you do this depends on whether you're on Windows or OS X.

If you're not using Gmail, you can create a backup of your email using just about any desktop email client. Here are guides for some of the more popular apps:

When you finish backing up your email, you can then go ahead and encrypt those files locally if you want.

How to Automate the Backups on Windows

How to Automatically Back Up and Purge Your Gmail Every 30 Days

GMVault features a sync feature that looks at your current backup and only backs up new messages. It can only look back one week though, so you'll want to run your backups once a week. On Windows, you can do this with Task Scheduler:

  1. Open up Task Scheduler (Control Panel > System and Security > Administrative Tools) in Windows
  2. Click Create Basic Task
  3. Name the task and set the trigger to Weekly (you can do this daily if you want to be extra safe)
  4. Click the Action tab and select Start a Program, then select the gmvault.bat file, by default it should be here: C:\Users\NAME\AppData\Local\gmvault\gmvault.bat
  5. Select Add Arguments and add this in, substituting your email for [email protected] sync -e -t quick [email protected]

That's it. You can right-click it in Task Scheduler and select Run to test it out.

How to Automate the Backups on Mac

How to Automatically Back Up and Purge Your Gmail Every 30 Days

In OS X, use Automator to run GMVault on a schedule:

  1. Open Automator (Applications > Utilities) and create a new document
  2. Select "Calendar Alarm"
  3. Add the Run Shell Script action
  4. In the text box, type in gmvault sync -e -t quick [email protected] replacing [email protected] with your information. Depending on where Gmvault is installed, you might need to include the directory there as well
  5. Save the file
  6. When it's saved, it will automatically open up Calendar with a new event. Set the calendar event to repeat once a week

Automator will run GMvault once a week to back up your email.

That's it! You're now backing up and deleting your email on a set schedule so you don't have to worry too much about hacks.


Comments

    Maybe don't recommend users run a script that they have to edit and could potentially delete all their email ever.

    You can also create backups regularly using Google's Takeout service.

    When you "takeout" your data, it creates several zip archives for you with ALL your e-mail, photos, documents, everything in drive, everything in google docs, all your contacts, and so on and stores your data in open source formats for each data type.

    What it saves for each type of data is listed here:
    https://support.google.com/accounts/answer/3024195

    Using takeout gives you everything, and not just gmail.

    emClient is a good free email client that works well with Gmail. I use it mainly as a email backup.

Join the discussion!

Trending Stories Right Now