Gdrive setup for downloading from Google Drive from command line#
Introduction#
gdrive is a command line application for interacting with Google Drive.
Prerequisites#
Before starting the setup, you need to create Google API credentials by following the instructions for creating Google API credentials.
Note: In Step 9 of the credentials setup, the App Domain fields might be mandatory, but you can leave them empty, click Publish, and move on to the next steps.
Local setup (MacOS)#
Download the latest binary from the release section of the GDrive GitHub.
Open your terminal and navigate to the folder containing the downloaded tar.gz file. Run the following command to unzip it:
tar -xzvf file_name
Move the binary to your system path and make it executable:
sudo mv gdrive /usr/local/bin/ sudo chmod +x /usr/local/bin/gdrive
Since the binary is not code signed, it may cause a security warning on MacOS. To work around this:
Run
gdrive version
in your terminalWhen the security warning appears, select “Go to Finder”
Right-click on the gdrive file and select “Open” to bypass the security warning
Open a new terminal window or tab.
Run the following command:
gdrive account add
Enter the Client ID and Client Secret you created in the Google API credentials step.
Follow the URL shown in the terminal and give access to GDrive.
Note down the account name from the last line of the output. You’ll need this for the remote setup.
gdrive is now ready to use on your local machine!
Remote Setup (Linux)#
Important: Complete the local setup first, as it’s a prerequisite for the remote setup.
Navigate to the folder where you want GDrive installed on your remote server.
Download the Linux version by copying the link of the latest release from the release section and run:
wget <insert_link>
Unzip the file:
tar -xzvf file_name
Make the file executable:
chmod +x gdrive
On your local machine, export your GDrive account configuration:
gdrive account export <account_name>
(Use the account name from step 9 of the local setup)
Transfer the exported account to your remote server:
scp LOCAL_PATH_OF_EXPORTED_ACCOUNT <username>@<ip_address>:PATH_ON_REMOTE_SERVER
LOCAL_PATH_OF_EXPORTED_ACCOUNT: Path where the account was exported in step 5
PATH_ON_REMOTE_SERVER: Path where you installed GDrive on the remote server
On the remote server, import the account:
<PATH_TO_GDRIVE>/gdrive account import PATH_ON_REMOTE_SERVER
PATH_TO_GDRIVE: Path where you downloaded and unzipped gdrive
PATH_ON_REMOTE_SERVER: Path where you transferred the exported account file
gdrive is now ready to use on your remote server!