AES Crypt

Securely Backup Your Linux Server to Google Drive with AES Crypt and Rclone

Backing up to the cloud can be a great option for data backup. However, despite what companies may say about their security policies you are at their mercy once you upload your content to their servers. However, if you encrypt it before you upload it you have double security. It may seem super paranoid but worst case you just have two layers of security and it takes a little bit longer to work with the raw file, but if there is a hack that breaks into Google Drive, or Onedrive, or B2 or whatever cloud service provider you are using you are now at the mercy of the hacker. However, if you encrypt your files before uploading them you are safe as long as the hacker has not broken 256 bit AES which is highly unlikely.

Companies with Google Apps for Work or students with a school Google Drive Account probably have unlimited cloud storage. Now this is great for work or school documents but it is also a fantastic solution for easy to access server backups. Google Drive has very fast upload speeds and it does not charge for bandwidth like it’s bucket storage sibling does. Therefore, you have unlimited storage for free and possibly for life if your institution retains your email account after you graduate. If you keep working for the same company you probably will have access to the account as long as you are an employee for the company. With Logistics aside Google Drive provides a reliable place to store content. In this tutorial we are going to compress a folder with tar and pipe that command to AES Crypt after the file is encrypted we will run Rclone to upload it to Google Drive. We will also write the program for full cron compatibility so that you can run this command every day, every week, or whenever you want to.

Requirements:

  1. A linux machine that is connected to the internet with tar, AES Crypt, and Rclone installed.
  2. If running Ubuntu 14.04: How to install AES Crypt
  3. If running Ubuntu 14.04: How to install Rclone and configure it to use Google Drive
  4. Secure shell access to the server.
  5. 10 minutes to complete the install and modify the script to fit your needs.

If you have AES Crypt and Rclone installed and configured you should be able to modify the script below and have it run successfully.

 cd /opt
    mkdir websitebackup
    cd websitebackup
    rm hwrweb-$(date +%Y-%m-%d).tar.gz
    rm hwrweb-$(date +%Y-%m-%d).tar.gz.aes
    tar -cvf - /var/www/html | aescrypt -e -p plaintextpassword - >hwrweb-$(date +%Y-%m-%d).tar.gz.aes
    sudo /usr/sbin/rclone copy hwrweb-$(date +%Y-%m-%d).tar.gz.aes googledrive-backup:HWR-Robotics-webserver
    rm hwrweb-$(date +%Y-%m-%d).tar.gz
    rm hwrweb-$(date +%Y-%m-%d).tar.gz.aes

Posted by admin, 0 comments