(2020-08-17 初稿 - 2021-01-18 修正)
Dropboxが無料では3台のPCしか接続できなくなり、オンラインストレージの活用方法を検討せざるを得ない状況になってしまいました。
ネットで検索すると、rcloneという筆者好みのコマンドラインインターフェース(CLI)のコマンドを見つけました。
もともとGoogle Driveは使っており、以前はgdriveというアプリをインストールして使っており、その頃にアップしたのが、以下のページになります。
・gdrive
インストール直後は利用していたのですが、debianのパッケージになっていないため、インストールが面倒で最終的には使うのをやめてしまいました。
ここでは、rcloneのインストール、GoogleDriveとDropboxへの接続設定、簡単な使い方について記述します。
インストールは、Debianのパッケージになっているので、以下のように簡単です。
sudo apt install rclone
これから、設定ファイルを作成しますが、以下のページを参考にしてインストールしました。多謝 m(__)m
$ rclone config
2020/07/21 19:17:41 NOTICE: Config file "/home/hoge/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n #<= n を入力
name> gdrive #<= gdriveと入力(好きな名前を)
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / A stackable unification remote, which can appear to merge the contents of several remotes
\ "union"
2 / Alias for a existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Hubic
\ "hubic"
14 / JottaCloud
\ "jottacloud"
15 / Local Disk
\ "local"
16 / Microsoft Azure Blob Storage
\ "azureblob"
17 / Microsoft OneDrive
\ "onedrive"
18 / OpenDrive
\ "opendrive"
19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
20 / Pcloud
\ "pcloud"
21 / SSH/SFTP Connection
\ "sftp"
22 / Webdav
\ "webdav"
23 / Yandex Disk
\ "yandex"
24 / http Connection
\ "http"
Storage> 12 #<= 12を入力
** See help for drive backend at: https://rclone.org/drive/ **
Google Application Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> #<= Enterのみ
Google Application Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> #<= Enterのみ
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"
scope> 1 #<= 1を入力
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id> #<= Enterのみ
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> #<= Enterのみ
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n #<= nを入力
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n #<= nを入力
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?(以下省略)
Log in and authorize rclone for access
Enter verification code> (ブラウザに表示されるcodeを入力)
Configure this as a team drive?
y) Yes
n) No
y/n> n #<= nを入力
--------------------
[gdrive]
scope = drive
token = {"access_token":(省略)}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #<= yを入力
Current remotes:
Name Type
==== ====
gdrive drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q #<= qを入力
$
少々長いですが、以上でGoogle Driveの設定は終了です。
続いて、Dropboxの設定を行います。
なお、本記述は、以下のサイトを参考にさせていただきました。多謝 m(__)m
$ rclone config
2020/07/25 17:27:55 NOTICE: Config file "xxxxxxx/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> dropbox <== 名前は dropbox としました。
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / A stackable unification remote, which can appear to merge the contents of several remotes
\ "union"
2 / Alias for a existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Hubic
\ "hubic"
14 / JottaCloud
\ "jottacloud"
15 / Local Disk
\ "local"
16 / Microsoft Azure Blob Storage
\ "azureblob"
17 / Microsoft OneDrive
\ "onedrive"
18 / OpenDrive
\ "opendrive"
19 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
20 / Pcloud
\ "pcloud"
21 / SSH/SFTP Connection
\ "sftp"
22 / Webdav
\ "webdav"
23 / Yandex Disk
\ "yandex"
24 / http Connection
\ "http"
Storage> 8
** See help for dropbox backend at: https://rclone.org/dropbox/ **
Dropbox App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> ここはブランクのままエンター
Dropbox App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> ここもブランクのままエンター
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n No を選択
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> n CUIしか使えないので Noを選択
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "dropbox"
Then paste the result below:
result>
hoge@pad:~$ rclone authorize "dropbox"
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Paste the following into your remote machine --->
{"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
<---End pastehoge@pad:~$
Dropboxの場合、アプリを介しての接続が3台までなのでブラウザ経由またはrcloneで『Dropbox』を開く場合は、3台までという制限にあたりません。
$ rclone ls gdrive:
$ rclone ls dropbox:
$ rclone copy rclone.txt gdrive:
$ rclone copy gdrive:text.txt .
rclone sync で同期できますが、リモート側のファイルをいきなり削除する可能性があるので、--dry-run オプションを付けてテスト実行した後、実行した方が良いです。
$ rclone sync source:path dest:path --dry-run # テスト実行
$ rclone sync source:path dest:path
rcloneは、確かに手動でファイルの同期やコピーを行わないといけないところは面倒な部分です。
しかし、ひとつのプログラムで複数のネットワークデータサービスを活用でき、とても便利だと思います。
特にDropboxは、無料で最大3台までの制限があるため、ラズパイで計測したデータの共有や3台以外のPCからの各種ファイルの共有には、かなり威力を発揮することとは間違いは無いでしょう。
皆さんもご活用を。また、何かわかりましたら追記します。