Sam Bunting

Uploading files to Google Drive via the command line

How you can use rclone to upload files to a cloud storage provider.

February 22, 2020

Google Drive

rclone

A few days ago I needed a way I can upload some files from a Ubuntu virtual machine to a cloud storage provider, one way I could have done it is by writing a Node (or any other language for that matter) script - but why create something which might not be as reliable as something that has been worked on years, and is reliable?

After a bit of Googling, I found out about rclone - It describes itself as “rsync for cloud storage”, and that’s pretty much exactly what it does.

Don’t want to use Google Drive?

Not a problem! rclone has support for a lot of cloud storage providers, including Dropbox, OneDrive and Box. It even supports more “developer focused” storage solutions such as Amazon Web Services S3, Azure Blob Storage and DigitalOcean Spaces.

Installation

Installation is really easy. For Linux and MacOS machines all you need to do is download a bash script and run it with sudo.

curl https://rclone.org/install.sh | sudo bash

Setup

Once it’s installed, you need to configure the destinations/providers of where you’d like to move your files too. This can be done by running:

rclone config

This is a step by step process, and is somewhat self explanatory, and if you’re using a different cloud storage platform, you might do things a bit differently.

Instead of me aimlessly explaining something which might be a bit confusing to a lot of people, you’re probably better off reading rclone’s documentation, If you’re planning on using Google Drive like I was, you can follow these steps.

During the process, if you are accessing the machine via SSH - you need to say “No” to “Use auto config?” - it will generate a URL you can go to from another machine instead.

Then what?

With everything installed and configured, you can pretty much just run a single command, and you’re good to go!

rclone move myImage.jpg googledrive:server

So, going through what this command means.

  • rclone tells the terminal to use rclone, the application we just installed.
  • move will move the file from the local machine, to wherever its remote location is, effectively deleting it.
  • myImage.jpg is the file I want to upload
  • googledrive is the name of the name of my remote, this might be different based on how you might have configured rclone. In the documentation, it’s named as “remote”.
  • :server is the path on my Google Drive, this means the “myImage.jpg” would be uploaded to the “server” folder.

I found the tool rather straightforward and easy to use - and I’ll probably be using it in the future!

Read more

That's the article!

I really hope you enjoyed this post or found it useful in some way!

Previous Article

Creating markdown files for a Gatsby blog with Hygen

How to use the command line to create boilerplate blog posts

January 12, 2020

Next Article

An introduction to Storybook

How to get started with a tool which can massively improve your UI development.

July 09, 2020