afb

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

Installing Rclone on Ubuntu 14.04

Backing up is crucial to the success of any website. However, backing up to cloud services such as Amazon S3, Google Drive, Google Bucket Storage, Yandex.Disk, and Backblaze B2 can be difficult and or time consuming to set up. However, Rclone makes that task so much easier. Today we are going to install Rclone on Ubuntu 14.04.

Yandex-Disk1.jpg

 

First you are going to want to go to their download page:

http://rclone.org/downloads/

 

You are going to want to download the appropriate version based on your system and whether it is 32 bit or 64 bit and whether or not it is running on ARM architecture.

We are going to use the 64 bit version which can be downloaded here:

http://downloads.rclone.org/rclone-v1.30-linux-amd64.zip




Once it is downloaded you are going to want to issue the following commands that are published on the Rclone website. Below I have copied and pasted the commands from their webpage, which is available here: http://rclone.org/install/

unzip rclone-v1.17-linux-amd64.zip
cd rclone-v1.17-linux-amd64
#copy binary file
sudo cp rclone /usr/sbin/
sudo chown root:root /usr/sbin/rclone
sudo chmod 755 /usr/sbin/rclone
#install manpage
sudo mkdir -p /usr/local/share/man/man1
sudo cp rclone.1 /usr/local/share/man/man1/
sudo mandb

If you want a complete install script I have composed one below that will download the file using wget and then implement the commands from Rclone’s website. It will also install the unzip package. The script is available below:

sudo apt-get install unzip -y

cd ~

wget http://downloads.rclone.org/rclone-v1.30-linux-amd64.zip

unzip rclone-v1.30-linux-amd64.zip

cd rclone-v1.30-linux-amd64

#copy binary file
sudo cp rclone /usr/sbin/
sudo chown root:root /usr/sbin/rclone
sudo chmod 755 /usr/sbin/rclone
#install manpage
sudo mkdir -p /usr/local/share/man/man1
sudo cp rclone.1 /usr/local/share/man/man1/
sudo mandb

 

Once it is installed you need to configure to work with your cloud storage host. The official configuration page is available here:

http://rclone.org/docs/

 

To setup Rclone for use with Google Drive you are going to want to type:

 

rclone config

n

#name of google drive remote host ex: googledrive-backup

googledrive-backup

6

#client_id leave blank

#client_secret leave blank

#If installing on a headless server type N

n

#you will be given a link to enter into your browser. The link will ask for your permission for Rclone to access your Google Drive account. Once permission is granted it will give you a verification code which you will copy and paste back into your ssh terminal.

#It will then ask you if the current setup is ok or if you want to edit it or delete it. If you are happy with the result press y which will set the remote host.

y

#If there are no more remote hosts that you want to add then you can type q to quit the configuration

q

Once you have your host set you can start copying files to it. For instance if we wanted to copy a file named test.txt into a folder on Google Drive named test (it doesn’t matter if the folder exists or not) we would enter the following:

rclone copy test.txt googledrive-backup:test

Note: If you are running rclone as an automated cron task you are going to need to include the full path to rclone or else it will not copy.

sudo /usr/sbin/rclone copy test.txt googledrive-backup:test

 

Congratulations! Now you are able to copy files from your server or computer to Google Drive with a few simple commands.

If you would like an offline version of this guide I have attached a pdf of it below:

Posted by admin, 0 comments

Installing AES Crypt on Ubuntu 14.04

Encryption is the backbone of modern computing and encrypting your files before uploading them to a cloud storage provider insures a higher level of security. AES Crypt is very simple to install on both Windows and Linux to make encryption very easy. In this tutorial we are going to install AES Crypt on Ubuntu 14.04.

First go to their website and download the appropriate file for your system (32bit or 64 bit) make sure it is the Gui version even though we will not be using the Gui version in this tutorial

https://www.aescrypt.com/download/

32 bit Linux https://www.aescrypt.com/download/v3/linux/AESCrypt-GUI-3.10-Linux-x86-Install.tgz

64 bit Linux https://www.aescrypt.com/download/v3/linux/AESCrypt-GUI-3.10-Linux-x86_64-Install.tgz

 

If you are on a 64 bit system you can use the following command to install AES Crypt:

wget https://www.aescrypt.com/download/v3/linux/AESCrypt-GUI-3.10-Linux-x86_64-Install.tgz

tar -zxf AESCrypt-GUI-3.10-Linux-x86_64-Install.tgz

sudo ./AESCrypt-GUI-3.10-Linux-x86_64-Install

 

You will be prompted with the following questions:

This will install AES Crypt for Linux on your computer.  Continue? [n/Y] Answer Y for the default install

Where do you want to install AES Crypt for Linux? [/usr/share/aescrypt] Press enter to complete the install unless you want to install AES Crypt to a different location.

 

If the installation completes it should display the following:

InInstalling Executables…         

InsIInstallation complete.

 

You can test the program by creating a file named test.txt and then encrypting it with the password of 123abc:

sudo nano test.txt

aescrypt -e -p 123abc test.txt

 

For more commands visit AES Crypt’s Linux usage page:

https://www.aescrypt.com/linux_aes_crypt.html

Below is a pdf of this guide for offline use:

Posted by admin, 0 comments