😽

Using gdrive in a LAMP environment started with Amazon Lightsail

2022/05/12に公開

Overview

Memorandum for using gdrive in a LAMP environment started with Amazon Lightsail, allowing backup of files to Google Drive, etc.

Procedure

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

You can access the server as follows.

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 programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the /usr/share/doc/*/copyright.

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:~$

Install golang

Install golang as follows.

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

You can check the version as follows.

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

Install gdrive

Execute the following.

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

You can check the version as follows.

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

## Authentication

Run the following to get the URL.

```bash
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:

Paste the verification code you got and you should see something like this

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

For example, the following will list the files on Google Drive.

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

Summary

This is a summary of how to use gdrive in a LAMP environment started with Amazon Lightsail.

The usage of gdrive can be found below. We hope you find it useful, for example, for backing up your files.

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

Discussion