Google drive is my favorite. In this post I am going to share a simple bash script which allows you to upload or sync files to drive.

If you are G suite user having unlimited google drive storage then you will absolutely love this script. I use the same script to upload the backups of this blog to my google drive account.


  • A google drive account
  • Google Client ID and Client Secret.
  • Basic linux skills.

To begin with, you need to first create a client ID and Client Secret in the google account to which you want to upload your files to. First head over to Google Cloud Console and create a new project. Then go to Library and enable Google Drive API.

Now go to credentials and create a new Auth Client ID. Select the application type "Other".


Now you will be provided Client ID and Client Secret. Copy the Client ID and Client Secret in a notepad and then download the config file and put it in a safe place.

Now that you have the credentials open a terminal or log-in via SSH if you want to run the script on a server. Execute the below command in the terminal to install the script.

curl --compressed -s | sh -s

After the installation of the script, execute the below commands to refresh the bashrc file.

. /.bashrc

Now we are going to create a temp file and upload it. And, since this is the first upload, it asks for the client ID and client secret. Run the below code in your terminal.

sudo touch temp
gupload temp

You will be asked for the client ID and client secret(the one you saved in your notepad). Copy and paste them in the terminal. Leave the refresh token blank and press enter. You will be prompted with a link. Click the link and log in to your google drive account.

Copy the verification code into your terminal. When asked for upload directory, just press enter and the script uploads the temp file. This means that the script is correctly configured.

You can now use the script to upload your files to google drive.

All you need to do is to enter "gupload" followed by the file or folder name.


There are many other scripts to achieve the same thing but this script is simple to use and actively maintained. Not only this, you can also create a sync job to sync a folder to your drive in the background. There are also other configurations you can make. Here is the original git repo of the script.

Alright. That brings us to the end of this post. Please comment if you like the post. Thanks!

Source/Credits: Labbots