Linux servers are powerful and flexible. With a modern GUI, things are generally fairly simple and straightforward. Say, for example, the process of syncing your server to a cloud account, like Amazon Drive, Dropbox, Google Cloud Storage, Google Drive, Microsoft Azure Blob Storage, Wasabi, etc. There are GUI tools, such as Cloudberry Backup, that do a great job of handling this task with a graphical front end.

But what if your server doesn’t include a desktop environment? Your terminal-only Linux server isn’t out of luck. With the help of rclone, you can sync files and directories to and from a veritable who’s who of cloud services. But how do you install rclone and make it work? I’m going to walk you through that very process.

I’ll be demonstrating on a freshly installed Ubuntu 16.04 Server and connecting it to a Google Drive account.

Installation

You won’t find rclone in the standard repositories. Instead, you must download the requisite file and install from there. Here’s how:

  1. Open a terminal window
  2. Issue the command curl -O curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
  3. Extract the zip file with the command unzip rclone-current-linux-amd64.zip
  4. Change into the newly created directory with the command cd rclone-*-linux-amd64

Now you must copy the included binary file into the proper directory and give it the correct permissions with the following steps:

  1. Copy the binary file with the command sudo cp rclone /usr/bin/
  2. Change the ownership of the binary file with the command sudo chown root:root /usr/bin/rclone
  3. Change the permissions of the binary file with the command sudo chmod 755 /usr/bin/rclone

At this point, you can issue the rclone command from within any directory.

SEE: Securing Linux policy (Tech Pro Research)

Configure rclone

Now we must configure rclone to work with the cloud service. The command to start this process is rclone config. Upon first run, you will be asked to create a new remote (Figure A).

Figure A

Type “n” and hit Enter on your keyboard. Give the new remote a name and hit Enter on your keyboard. You will then be asked to select the type of remote (Figure B).

Figure B

Since we’re creating a remote for Google Drive, type 9 and hit Enter on your keyboard. You will then be asked a few questions. The first is client_id>. Leave this blank by simply hitting Enter on your keyboard. The second question is client_secret>. Leave this one blank as well.

Because we are installing this on a headless server, type “n” at the Auto Config option. You will be presented with a link. Copy that link and then paste it into a desktop browser. You will then be asked to select your Google account to be used. Once you’ve allowed access, you will be presented with an access code. Copy that code and then paste it into the terminal prompt of the headless server.

The final question asks if you want to configure this remote as a team drive. Type “n” and hit Enter on your keyboard. Finally type “y” to okay the configuration. You can then set a configuration password to secure away the information for the remote. I highly recommend you do this. Type “s”, hit Enter on your keyboard, and then, when prompted, type and verify a password for the configuration.

You can then type “q” to exit the configuration menu and be returned to the main menu. Your remote will be listed (Figure C).

Figure C

SEE: Server deployment/migration checklist (TechRepublic)

Usage

You can get a listing of the remote directories with the command:

rclone lsd 'Google Drive':

To list all of the files on your remote, the command would be:

rclone ls 'Google Drive':

To copy a local directory to a folder in your remote (in this case, Google Drive), the command would be:

rclone copy /PATH/TO/DIRECTORY remote:FOLDER

Where /PATH/TO/DIRECTORY is the local directory and FOLDER is the name of a folder on your Google Drive. For example, we have the local folder /home/jack/data and we want to copy it to the folder data on the Google Drive remote. The command for this would be:

rclone copy /home/jack/data 'Google Drive':data

The directory will be copied to the data folder on your Google Drive.

And that’s the basics for rclone. If you need more information, make sure to install the rclone man page with the following commands (issued from within the rclone installation directory):

sudo mkdir -p /usr/local/share/man/man1
sudo cp rclone.1 /usr/local/share/man/man1/
sudo mandb

Now you can issue the command man rclone and read all about the available command line options.

A flexible syncing solution

Your headless Linux server doesn’t have to be without a cloud sync solution. Using rclone might not be as simple as some of the available GUI tools, but it does make syncing your headless Linux server with numerous cloud services possible. Give rclone a go and see if it doesn’t serve you well.

Subscribe to the Cloud Insider Newsletter

This is your go-to resource for the latest news and tips on the following topics and more, XaaS, AWS, Microsoft Azure, DevOps, virtualization, the hybrid cloud, and cloud security. Delivered Mondays and Wednesdays

Subscribe to the Cloud Insider Newsletter

This is your go-to resource for the latest news and tips on the following topics and more, XaaS, AWS, Microsoft Azure, DevOps, virtualization, the hybrid cloud, and cloud security. Delivered Mondays and Wednesdays