This is an old revision of the document!


Data transfer with Google Drive

Currently, there is no preinstalled application that lets users transfer files to and from Google Drive. It is possible, however, to install a third-party tool in your /home directory called Google Drive Upload to achieve this. With this tool you can download and upload files and directories to your (RUG) Google Drive.

Please be mindful of your data management and data archival requirements. Google Drive is a very helpful tool to save and access files but it is not recommended as an appropriate storage solution for research data archival. Consider using tools hosted at the university like the RDMS. For questions regarding data management, you can contact the Digital Competence Center (dcc@rug.nl) or the data steward in your faculty.

For most use cases, simply following the instructions in the installation page will be enough. The page contains more information in case you need to customize the installation further, but this is not a requirement.

In essence, downloading and installing Google Drive Upload can be done by running one line of code on your bash console in your $HOME directory.

  1. Log into Hábrók on any of the access nodes from a terminal, for example ssh pXXXXXX@login1.hb.hpc.rug.nl.
  2. Add a few lines to your .bashrc file by running the line suggested by the application. It will look something like: echo '[ -f “${HOME}/.google-drive-upload/bin/gupload” ] && [ -x “${HOME}/.google-drive-upload/bin” ] && PATH=“${HOME}/.google-drive-upload/bin:${PATH}”' » /homeN/pXXXXXX/.bashrc. If you are copying the line from this page, then make sure you replace /homeN/pXXXXXX/.bashrc with your own p/s- number and /home directory!

You can verify that this worked by restarting your terminal and calling gupload –help. You should see a help message if the installation was successful.

There are extended instructions in the initial setup page of the official documentation, but here we detail the necessary steps to connect the application to your RUG Google Drive.

  1. Make sure you are logged in with your university account if you wish to access your RUG Google Drive and enable the Google Drive API on your Google account. You can do so by accessing the Google Developer console.
  2. Create a new project. To do so, type “Create a project” in the search bar at the top. Create this project in the 'rug.nl' organization to use your University Google Drive. Choose a descriptive name for your project, such as 'gupload'.
  3. It will take a few seconds for your project to be created and the project dashboard should open automatically. If it doesn't, open it manually.
  4. On the project dashboard, open the side bar menu on the top left and navigate to 'APIs & Services' → 'Enable APIs & services'.
  5. On the 'APIs & Services' page, select Enable 'APIs and Services' at the top. This will take you to the 'API Library' page. On this page, search for 'Google Drive API' and enable it.
  6. The previous step should open the 'Google Drive API' page. On it, click the 'Create credentials' link at the top of the page.
  7. On the Create credentials menu, select the Google Drive API and indicate that you will be accessing User data. Name the app something descriptive like 'gupload' and add your email in the support email and developer contact fields. You don't need to add any scope to the credential.
  8. On the OAuth Client ID section, choose 'Desktop App' as the application type and name it something like 'gupload app'.
  9. You should now see a Client ID. Make sure you download this. The Google Drive API is now complete!
  10. On your terminal in Hábrók, after also having done the steps in the previous section.
    1. Create a dummy file to upload from your $HOME directory. For example cd $HOME && echo “This is a dummy file!” » dummy_file.txt.
    2. Upload the file by calling gupload dummy_file.txt. You will be prompted for your Client ID and Client SECRET. Using a regular text editor like notepad open the json file you downloaded earlier and paste the corresponding values.
    3. When prompted for a refresh token, leave the field blank and press Enter. You will now see a URL for a web page.
    4. Without closing the current session, start a new SSH connection on the same access node in Hábrók and open a browser window by writing firefox. Paste the URL from the previous step on your browser. This should take you to a Google login page. Login with your university account and grant permissions to gupload.
    5. Go back to your terminal session and press Enter. You will be asked for the root folder ID or URL of the Google Drive folder you want to upload to. Choose one, or press Enter to leave it to the default (the root directory of your account). The setup is now complete.
    6. Go to your Google drive and confirm the file dummy_file.txt is present and contains the text “This is a dummy file!”.

Once the initial setup is complete, transferring files to and from Google Drive is simple as uploading the dummy file in the previous section. To upload a file to your Google Drive, a simple call to gupload my_file will place the file in the root directory of your Drive by default. You can upload to a different directory as well, by doing something like:

gupload filename/foldername/file_id/file_link -c gdrive_folder_name