In this article, We will see how-to DriveSync local files with Google Drive from Linux CLI. Google Drive is widely used for cloud storage. It allows us to access, upload, or download the documents or files inside our drive from any location or device, provided proper authentication.
DriveSync is a command-line interface(CLI) tool that synchronizes our files which are on our local system to Google drive via a command-line interface. We can download new remote files and upload our local files to our drive and delete, update our files both locally and on Google Drive.
Features Of DriveSync:
DriveSync provides the following main features:
- Download files remotely
- Upload local files to Google Drive
- Upload and download files with size based on our preference. By default, it is set to512MB
- Delete or Update files in both local drive and Google Drive
- Enable Autosync using cronjob
Follow the below steps to successfully install DriveSync to your Linux system:
Step 1: So first thing we need is to have ruby installed. It can be done using the below commands:
- Command to install ruby in Ubuntu:
sudo apt install ruby ruby-bundler
- Command To install ruby In Arch Linux:
sudo pacman -S ruby ruby-bundler
Step 2: Next, we need to install DriveSync using the below command:
$ git clone https://github.com/MStadlmeier/drivesync.git $ cd drivesync/ $ bundle install
Now we have our DriveSync successfully installed in our system.
Step 3: Next, we will run the following command in order to sync the files
When you run the above command you will get a URL as shown below:
Now open the link with your browser and it will redirect you to the Google sign-up page. Click on your preferred email id and enter your password. Then in end, it will give you a page as shown below:
Step 5: Here click on allow the button to give access between DriveSync and your Google Drive. This will lead you to the page with an authorization code as shown below. Copy the code and paste it in the terminal, and press the Enter button.
Step 6: Then you will see it will sync all your files from Google Drive to your local folder as shown below.
We can see all files which were synced from our Google Drive to local under the drive folder in /home/user/documents/ in the below image:
DriveSync configuration files are located in the location /home/user/.drivesync/ .
You can make any changes by modifying the config.yml file. The config.yml File contains only those configuration options which are rarely changed during our period usage.
In order to test this, we are going to create a folder called Verify_drivesync and we will upload an image (say image.png). Then we are going to execute the below command:
Here You can see the image .png file is uploading to our Google Drive
As you can see in the below image, under the folder Verify_drivesync, the image has been uploaded to our Google Drive
In Terminal use the below command:
\ crontab -e
This will ask for the choice of text editors you want to use. Here we used nano.
Then enter the below text to file and save the file and close it. This will auto-sync for every one minute
*/1 * * * * ruby ~/drivesync/drivesync.rb
Here we have added an image to test this. Here you can see it uploads the image.