Jean Galea

Health, Wealth & Happiness

  • Home
  • Start Here
  • About
  • Investing
  • Podcast
  • Padel
  • Contact
  • Search

How to Backup Gmail on a Synology Diskstation via GMVault

Last updated: January 07, 201917 Comments


In one of my previous articles, I wrote about backing up Gmail via Gmvault on a Mac. This time I want to go one step further in terms of convenience, and show you how to install Gmvault on a Synology Diskstation and have it back up your Gmail accounts. This will eliminate the need for your computer to be on and also saves processing power on your system, since everything is handled by the Diskstation.

Installing Python 2.7

The first set of steps will have us install Python 2 on the DiskStation, since it’s needed for Gmvault to run.

  1. Log into Synology NAS as an admin user (can be your own username if you are in the Administrators group) and go to Main Menu -> Package Center -> Settings and set Trust Level to Synology Inc. and trusted publishers.
  2. In the Package Sources tab, click Add, type “SynoCommunity” as Name and “https://packages.synocommunity.com/” as Location and then press OK to validate.
  3. Go back to the Package Center and install the Python 2.7 package (“Python”) in the Community tab. (Synology provides Python 3, so if a later version of GMVault is made compatible then you won’t need to do steps 1-4).
  4. Remove the Package Source and reset the Trust Level to “Synology Inc.”

Set up Folders for Gmvault backups

We now have Python 2.7 installed. Nex,t we need to set up the folders to keep the backups in. Go to Control Panel -> Shared Folder. Create a new folder called Gmvault.

[Optional] You can also encrypt the contents of the folder by clicking the folder then clicking on the Edit button and then on the Encryption tab. Then click the checkbox next to Encrypt this shared folder and enter an encryption key.

Enabling SSH

Go to Control Panel -> Terminal & SNMP -> Enable SSH service.

If you have Security Advisor enabled it might complain about the SSH service not being secure if you use the default port of 22, which I didn’t bother changing as I was only logging in via my local network.

Installing Pip, the Python Virtual Environment and Gmvault

Open a Terminal window on your Mac and SSH into the Diskstation using a user with admin access.

Make sure you navigate your way to volume1 or whichever volume you will be using to set up Gmvault on and store the backups. In that volume, you should find the Gmvault folder we created earlier. Make sure you are in that directory then follow the next steps:

  1. wget https://bootstrap.pypa.io/get-pip.py
  2. sudo python get-pip.py
  3. sudo pip install virtualenv
  4. rm get-pip.py
  5. virtualenv gmvault_env
  6. cd gmvault_env
  7. sudo pip install gmvault

What we did above is to install the pip utility that is needed to install Python packages/modules, followed by installing virtualenv. Virtualenv is a tool to create isolated Python environments. It creates a folder which contains all the necessary executables to use the packages that a Python project would need. More info about it and how it works can be found here.

With those in place we created an environment for Gmvault and installed it using pip.

Setting up Gmvault

We are now at the stage where we already have Gmvault and can start having some fun with it.

To make sure that Gmvault has installed correctly, type in the following command:

  • gmvault -h

This should display the help for Gmvault, if it does, you’re good to go. Follow the next steps:

  • gmvault sync -t full –db-dir /volume1/Gmvault/backups/YOUREMAILADDRESS/ –emails-only –no-compression my_email…@gmail.com
  1. Gmvault will then prompt to open a web browser to grant OAuth2 access.
    Press Enter to open the browser – which won’t happen!
  2. Highlight the web address that Gmvault displays.
  3. Open a new window in your web browser and paste the web address into the address bar.
  4. Login to Google Mail and grant access to Gmvault.
  5. Copy the authentication token that Google will display and paste into the SSH session.

That’s it! Gmvault should now continue and download the emails.

If you’re curious about the parameters I used when executing gmvault, have a look at the in-depth guide on the Gmvault site which details all the possible parameters.

Note: For security purposes, you can now disable the SSH service. It is recommended to only activate this service whenever you need it, especially if you make your Diskstation available over the internet.

Encryption

While you can choose to encrypt using gmvault itself, however, I decided to use Synology’s own facility for encrypting folders. For more information about Synology’s encryption, you can refer to this article. The official Synology guide is also a handy reference, as is their page on managing keys.

Further Improvements

There are additional steps you can take to improve this workflow, for example setting a recurring automated task that runs, say, on a daily basis. This would make the backups work without your intervention.

Have you set up automated backups for your Gmail accounts? What’s your take on the subject?

Filed under: Tech

Related

About Jean Galea

Jean Galea is a dad, amateur padel player, host of the Mastermind.fm podcast, investor and entrepreneur.

Comments

  1. adam says

    October 14, 2020 at 5:04 pm

    I keep receiving “error: argument -m/–multiple-db-owner: ignored explicit argument ‘ails-only'” when executing gmvault sync -t full –db-dir /volume1/Gmvault/backups/YOUREMAILADDRESS/ –emails-only –no-compression my_email…@gmail.com

    Reply
  2. Adam says

    August 31, 2020 at 5:50 pm

    Thanks for the instruction. I was able to follow every step until I stumbled upon gmvault sync -t full –db-dir /volume1/Gmvault/backups/YOUREMAILADDRESS/ –emails-only –no-compression my_email…@gmail.com

    I am confused as to whether YOUREMAILADDRESS is the same as my_email…@gmail.com

    Let’s suppose my_email…@gmail.com is actually [email protected]. What should be the correct syntax for the above? Thanks.

    Reply
  3. Russell says

    July 3, 2019 at 6:44 pm

    you shouldn’t use sudo with pip. in this case, you’re needing to use sudo because the virtual environment isn’t actually being utilized here; therefore, sudo is needed to install gmvault in to the system’s python environment.

    To activate the virtual environment, source the activate script.

    > source gmvault_env/bin/activate

    Reply
  4. Bart says

    May 23, 2019 at 7:35 pm

    gmvault has been blocked by Google so don’t bother trying.

    Reply
  5. Christian says

    January 27, 2019 at 5:52 pm

    Hi!

    Any Updates on the automation? When i set up a task in dsm IT seems that i have to do the Authentication step again, but there is no interactive mode.

    Reply
    • Christian says

      February 14, 2019 at 10:56 am

      Hi!

      I have solved the problem by using a docker container that backups to data periodically to my Diskstation. For more than one account I deploy multiple container.

      Reply
      • Jean says

        February 15, 2019 at 8:04 pm

        Thanks for sharing Christian.

  6. Jerry says

    January 7, 2019 at 5:44 am

    You are my hero Jean!

    A couple comments to assist anyone who may attempt this:
    – I had to enable user home service.
    – I had to use sudo for “pip install gmvault”

    Reply
    • Jean says

      January 7, 2019 at 6:08 pm

      Thanks Jerry, added the modification in case others run into the same problem.

      Reply
  7. Avatar says

    November 30, 2018 at 6:09 pm

    This was helpful – thank you!

    Mini feedback:
    * 1. wget https://bootstrap.pypa.io/gepipt-pip.py
    This has to be https://bootstrap.pypa.io/get-pip.py

    * 7. pip install gmvault
    For me this only worked with sudo due to missing rights

    * gmvault sync -t full –db-dir /volume1/Gmvault/backups/YOUREMAILADDRESS/ –emails-only –no-compression my_email…@gmail.com
    This should have “–” in front of db-dir instead of just “-”

    Thanks again. Today too many people don’t take the time to document their approach and help others. Much appreciated that you took the time.

    Reply
    • Jean says

      December 8, 2018 at 12:28 am

      You’re welcome Bartel, I will update the post accordingly.

      Reply
  8. Mike says

    August 24, 2018 at 6:35 am

    Your article says – “At this point you will realise that we haven’t yet automated anything, and the automation part is an essential reason of why we’re doing this thing, so let’s proceed with getting that in place too.” and then pretty much ends?????

    Reply
    • Jean says

      August 24, 2018 at 9:34 am

      That sentence was left in there by mistake, I now removed it. I haven’t yet gotten around to automate the process as I had some issues when setting it up, but it’s on my todo list. Any tips on how to do that would be great.

      Reply
  9. Ron says

    June 22, 2018 at 5:01 pm

    Hello Jean!

    I stumbled onto your page, attempting to find a method of constant gmvault backups, as my last solution unexpectedly stopped working (and I can no longer find the resource I used to set it up).

    During the pip install (the step “wget https://bootstrap.pypa.io/gepipt-pip.py“), I am met with a 404 error “Not found”. I thought it was a spelling error on the ‘gepipt-pip.py’ section, but attempting random combinations yielded the same error.

    Would you happen to know another source for this material?

    Thanks in advance!

    Reply
    • Doc Rock says

      July 21, 2018 at 2:44 am

      edit line to getpip-pip.py

      Reply
    • DocRock says

      July 21, 2018 at 2:46 am

      correction

      should read https://bootstrap.pypa.io/get-pip.py

      Reply
      • Jean says

        July 22, 2018 at 1:30 pm

        Thanks, fixed.

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords or links in the name field.

Subscribe to my Newsletter

Success

Instagram

Powered by Spotlight

Latest Padel Match

Jean Galea

Investor. Dad. Global Citizen. Padel Player.

Follow @jeangalea

  • Email
  • Instagram
  • LinkedIn
  • RSS
  • Twitter
  • YouTube
  • Impossible List
  • Start a Blog
  • Affiliate Disclaimer
  • Search
  • Cookies
  • Contact

Copyright © 2021 · Hosted at Kinsta · Built on the Genesis Framework