How to Upload Files to Google Drive From Linux
In that location'due south still no official Linux client for Google Drive, but you can back upwardly to your Google Drive using the rclone
utility right from the control line. We show you how.
Where'due south Google Drive on Linux?
Despite promising Linux back up "coming before long" back in 2012, at that place'southward no indication that Google will e'er produce a native Linux client for Google Drive. There are several unofficial third-party solutions, such equally InSync, overGrive and ODrive, and some file browsers allow integration with your Google Drive, such as Files in GNOME.
The third-party applications are commercial products, requiring either an outright buy or a subscription. They piece of work well they don't cost much, and in fact, overGrive does have a free version, offering limited functionality for no cost.
But what if yous want to create and run backups from the control line? Or to incorporate that functionality into scripts? That's all possible thanks to an amazing application called rclone
. In fact, with rclone
you can support, download, and synchronize files to over twoscore different deject solutions. It's similar rsync for clouds.
Installing rclone
rclone
almost certainly won't be installed on your Linux computer by default. Happily, there'south an installation script that should work on all distributions. The installation procedure uses scroll. On the computers used to research this article, Fedora 31 and Manjaro xviii.1.0 already had curl
installed butroll
had to exist installed on Ubuntu 18.04 LTS.
On Ubuntu, run this command to install it:
sudo apt-get install curlicue
Once curlicue
has been installed, install rclone
with this command:
whorl https://rclone.org/install.sh | sudo bash
When the rclone
installation has finished, you'll see a success bulletin.
This has installed the rclone
program on your Linux reckoner. The next step is to run through the setup process and authenticate rclone
to admission your Google Drive.
Creating an rclone Remote Connection
Connections to remote deject services are called "remotes" in the rclone
world. Nosotros need to create one for Google Drive. Kickoff the rclone
configuration process with this command:
rclone config
In that location are a lot of questions in the configuration process. Simply don't be disheartened, many of them tin be left at their default values and simply accepted by pressing "Enter."
rclone
tells united states at that place are no remotes configured. Printing "northward" and press "Enter" to create a new remote. It volition prompt you for a name. We're going to call it "google-bulldoze." Use any name yous like.
A long card allows you to choose the type of storage you're creating a remote connectedness to.
Scroll through the list until you see the entry for Google Drive, and make a annotation of its number.
We can see that in this instance, it is number 13. Enter this every bit the storage type and press "Enter."
You're prompted for a Google Application Client ID. Press "Enter" to have the default.
You're then prompted for a Google Application Customer Cloak-and-dagger.
Again, but printing "Enter." You're asked to provide the scope that rclone
will have when it is operating on your Google Drive. Printing "ane" then press "Enter."
For the "ID of the root folder", just press "Enter."
At the "Service Business relationship Credentials" prompt, printing "Enter."
At the "Edit advanced config" prompt, just press "Enter." At the "Apply automobile config" menu, press "y" and then press "Enter."
This causes rclone
to communicate to your Google Drive, and to launch your browser to let yous to give permission for rclone
to collaborate with your Google Bulldoze.
In your browser window, click on the Google business relationship you wish to apply.
Click the "Permit" button to let rclone
to have admission to your Google Bulldoze.
When cosign has completed, y'all'll come across a "Success!" bulletin in the browser window. You tin can close the browser and return to the terminal window.
At the "Configure this as a team drive" prompt, type "n" and then press "Enter."
At the "Yes, Edit, Delete" carte du jour type "y" and and then press "Enter."
At the final carte du jour, type "q" and press "Enter."
The rclone Support Script
The rclone
awarding is very feature-rich. That's great, but information technology does mean in that location are a lot of options. The command we're going to expect at below copies files from your local computer to your Google Drive. This is a one-fashion re-create to the cloud; it isn't a two-way synchronization between your Google Drive and your local computer—although rclone
can practise that. We're using this as a bones form of off-site backup.
Type (or copy and paste) this into a text editor and save it to your computer. Nosotros called it gbk.sh
. You can call information technology whatever makes sense to you.
#!/bin/bash /usr/bin/rclone copy --update --verbose --transfers xxx --checkers 8 --contimeout 60s --timeout 300s --retries three --low-level-retries ten --stats 1s "/home/dave/Documents" "google-bulldoze:LinuxDocs"
Here's what the parameters hateful:
- re-create: Copy the files from the local reckoner to the remote storage, skipping over files that are already present on the remote storage.
- –update: Skip any files that are on the remote storage that take a modified time that is newer than the file on the local computer.
- –verbose: Gives information most every file that is transferred.
- –transfers 30: This sets the number of files to copy in parallel.
- –checkers 8: How many "checkers" to run in parallel. Checkers monitor the transfers that are in progress.,
- –contimeout 60s: The connection timeout. Information technology sets the time that
rclone
volition try to make a connection to the remote storage. - –timeout 300s: If a transfer becomes idle for this corporeality of time, it is considered broken and is disconnected.
- –retries iii: If at that place are this many errors, the unabridged copy action will exist restarted.
- –low-level-retries 10: A depression-level retry tries to repeat one declining operation, such as a single HTTP request. This value sets the limit for the number of retries.
- –stats 1s:
rclone
can provide statistics on the transferred files. This sets the frequency of update of the statistics to one second. - "/home/dave/Documents": The local directory to nosotros're going to copy to the remote storage.
- "google-drive:LinuxDocs": The destination directory in the remote storage. Note the use of "google-drive", which is the name we gave to this remote connectedness during the the
rclone config
sequence. Likewise notation the colon ":" that is used as a separator between the remote storage name and the directory name. Subdirectories are separated by the usual "/" forward slash. If the destination directory does non be, it will be created.
Some of these values are the defaults, only we've included them here so that we can discuss them. That way, if yous need to alter a value, yous know which parameter to adapt.
Make the script executable with this command:
chmod +x gbk.sh
Running the Back Up Script
Our back upward script is going to copy our Documents folder to our Google Drive. In our Documents binder, we've got a collection of sheet music.
We can launch the dorsum up script with this control:
./gbk.sh
We asked for statistics updates every ane 2d (--stats 1s
), and nosotros as well asked for verbose output (--verbose
). It'll come as no surprise then that we get a lot of screen output. It'south usually a skillful selection to plough on verbose output for new functionality so that you can spot problems. You can reject the amount of output once you lot're happy things are running smoothly.
Nosotros get a terminal summary telling usa 60 files were transferred with no errors. The transfer took roughly 24 seconds.
Permit's check on our Google Drive and see what happened in our cloud storage.
A "LinuxDocs" directory has been created, and then that looks promising. If nosotros double-click it to take a wait inside, we can run into that the files have all been transferred to our Google Drive.
Using rclone to View Files On Google Drive
We can use rclone
to peek into the folder on Google Drive, correct from the terminal window:
rclone ls google-drive:/LinuxDocs
The Tip of the Iceberg
That's nifty that we can perform this type of copy straight from the command line. We can comprise the use of our cloud storage into scripts, and nosotros could schedule the execution of back up scripts using cron
.
rclone
has an absolute wealth of commands, you're encouraged to cheque out their documentation and excellent website. We've barely scratched the surface here, and a bit of reading and playing with rclone
will pay dorsum the endeavour many times over.
Strictly speaking, this isn't a truthful backup. Information technology is an off-site, remote copy of your files and data, which is definitely a skilful matter to have, but it is only a copy of files. It doesn't offering versioning or other features that truthful backup solutions would offering.
And then use rclone
in conjunction with other backup techniques. As another layer to an existing backup regime rclone
is an easy way to get your data stored in a location that is geographically removed from your home or office. And that'south got to be a adept thing.
Source: https://www.howtogeek.com/451262/how-to-use-rclone-to-back-up-to-google-drive-on-linux/
0 Response to "How to Upload Files to Google Drive From Linux"
Post a Comment