Overview

This is a memo for using gdrive in a LAMP environment launched on Amazon Lightsail. This enables file backups to Google Drive, among other things.

Steps

First, access Amazon Lightsail and press the “Connect using SSH” button on the target instance.

You can access the server as shown below.

Linux ip-172-26-5-202 4.19.0-19-cloud-amd64 #1 SMP Debian 4.19.232-1 (2022-03-07) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
       ___ _ _                   _
      | _ |_) |_ _ _  __ _ _ __ (_)
      | _ \ |  _| ' \/ _` | '  \| |
      |___/_|\__|_|_|\__,_|_|_|_|_|

  *** Welcome to the LAMP packaged by Bitnami 7.4.28-14                 ***
  *** Documentation:  https://docs.bitnami.com/aws/infrastructure/lamp/ ***
  ***                 https://docs.bitnami.com/aws/                     ***
  *** Bitnami Forums: https://community.bitnami.com/                    ***
Last login: Thu May 12 03:25:13 2022 from 72.21.217.186
bitnami@ip-172-26-5-202:~$

Installing golang

Install golang as follows.

bitnami@ip-172-26-1-210:~$ sudo apt-get install golang

You can verify the version as follows.

bitnami@ip-172-26-1-210:~$ go version
go version go1.11.6 linux/amd64

Installing gdrive

Run the following.

bitnami@ip-172-26-1-210:~$ go get github.com/prasmussen/gdrive

You can verify the version as follows.

bitnami@ip-172-26-1-210:~$ ./go/bin/gdrive version
gdrive: 2.1.1
Golang: go1.11.6
OS/Arch: linux/amd64

Authentication

When you run the following, a URL is displayed.

bitnami@ip-172-26-1-210:~$ ./go/bin/gdrive about
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=...

Enter verification code:

After pasting the obtained authentication code, the following is displayed.

User: XXX
Used: XXX TB
Free: XXX B
Total:
Max upload size: XXX TB

For example, running the following lists the files on Google Drive.

bitnami@ip-172-26-1-210:~$ ./go/bin/gdrive list

Summary

This summarizes the method for using gdrive in a LAMP environment launched on Amazon Lightsail.

You can check gdrive usage at the link below. I hope this is helpful for use cases such as file backups.

https://github.com/prasmussen/gdrive#usage