Terminal friendly gdrive

To easily backup your trained model, dataset, logs, etc. to your Google Drive using a simple CLI, you can follow these steps:

  1. First, download the gdrive CLI tool by running the following commands:
    wget https://github.com/prasmussen/gdrive/releases/download/2.1.1/gdrive_2.1.1_linux_386.tar.gz
    tar -xvf gdrive_2.1.1_linux_386.tar.gz
    ./gdrive
    
  2. To make the gdrive command accessible from any directory, you can create a directory of your choice to store the gdrive binary file, such as /home/sagar/bin/. Then, add the path to this directory to your $PATH environment variable in your ~/.bashrc file by running:
    mkdir /home/sagar/bin/
    export PATH=$PATH:"/home/sagar/bin/" # enter this in your bashrc
    
  3. Now, copy the gdrive binary file to your chosen directory:
    cp gdrive /home/sagar/bin/
    
  4. To upload an entire directory recursively to your Google Drive, you can use the following command:
    gdrive upload --parent <destination_id> --recursive <source_directory>
    

    Replace <destination_id> with the ID of the destination folder in your Google Drive and <source_directory> with the path to the directory you want to upload. E.g. https://drive.google.com/drive/u/1/folders/118mOZ771FOJiQMKRxX this is indeded upload web-link of your google-drive, the destination id is 118mOZ771FOJiQMKRxX

  5. To upload a single file to your Google Drive, you can use the following command:
    gdrive upload --parent <destination_id> <source_file>
    

    Replace <destination_id> with the ID of the destination folder in your Google Drive and <source_file> with the path to the file you want to upload.

By following these steps, you can easily backup your files to your Google Drive using a simple CLI.

Reference

Github: prasmussen/gdrive