Lucky Fox IT & Telecom Knowledge Forum

在Synology 上使用 rclone 掛載 Cloud Drives

rclone

rclone 是一個管理雲端儲存的程序,只支援command-line。
此文會提供於 Synology NAS上使用ssh 安裝,設定以及掛載Google Drive 以及 Google Shared Drive (前稱 Google Team Drive)。

  1. 安裝 rclone: SSH 進 Synology,再用 sudo -i 獲取 Root 權限
  2. 運行 curl https://rclone.org/install.sh | sudo bashimage
  3. 運行 rclone config,以下使用 Google Drive 作示範
  4. 以下是 config 的 Terminal output:

[email protected]:~# rclone config
Enter configuration password:
password:
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> GoogleDrive
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 / 1Fichier
\ “fichier”
2 / Alias for an existing remote
\ “alias”
3 / Amazon Drive
\ “amazon cloud drive”
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, Tencent COS, etc)
\ “s3”
5 / Backblaze B2
\ “b2”
6 / Box
\ “box”
7 / Cache a remote
\ “cache”
8 / Citrix Sharefile
\ “sharefile”
9 / Dropbox
\ “dropbox”
10 / Encrypt/Decrypt a remote
\ “crypt”
11 / FTP Connection
\ “ftp”
12 / Google Cloud Storage (this is not Google Drive)
\ “google cloud storage”
13 / Google Drive
\ “drive”
14 / Google Photos
\ “google photos”
15 / Hubic
\ “hubic”
16 / In memory object storage system.
\ “memory”
17 / Jottacloud
\ “jottacloud”
18 / Koofr
\ “koofr”
19 / Local Disk
\ “local”
20 / Mail.ru Cloud
\ “mailru”
21 / Mega
\ “mega”
22 / Microsoft Azure Blob Storage
\ “azureblob”
23 / Microsoft OneDrive
\ “onedrive”
24 / OpenDrive
\ “opendrive”
25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ “swift”
26 / Pcloud
\ “pcloud”
27 / Put.io
\ “putio”
28 / QingCloud Object Storage
\ “qingstor”
29 / SSH/SFTP Connection
\ “sftp”
30 / Sugarsync
\ “sugarsync”
31 / Tardigrade Decentralized Cloud Storage
\ “tardigrade”
32 / Transparently chunk/split large files
\ “chunker”
33 / Union merges the contents of several upstream fs
\ “union”
34 / Webdav
\ “webdav”
35 / Yandex Disk
\ “yandex”
36 / http Connection
\ “http”
37 / premiumize.me
\ “premiumizeme”
38 / seafile
\ “seafile”
Storage> 13
** See help for drive backend at: Google drive **

Google Application Client Id
Setting your own is recommended.
See Google drive for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id> *************** client ID obtained from Google API ***************
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> ******** Secret Obtained from Google API *****************
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
ID of the root folder
Leave blank normally.

Fill in to access “Computers” folders (see docs), or for rclone to use
a non root folder as its starting point.

Enter a string value. Press Enter for the default ("").
root_folder_id>
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.

Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.

Enter a string value. Press Enter for the default ("").
service_account_file>
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Remote config
Use auto config?

[GDHKU]
type = drive
client_id = *******
client_secret = ******
scope = drive
token = {"access_token”:””,”token_type":“Bearer”,"refresh_token”:””,”expiry”:””******}

y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name Type
==== ====
GoogleDrive 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

  1. 新增一個你想把Google Drive 掛載到的資料夾,再使用以下 command 掛載 rclone --config=/root/.config/rclone/rclone.conf mount GoogleDrive: /volume2/sync/GDHKU --allow-other --allow-non-empty --buffer-size 32M --vfs-read-chunk-size=32M --vfs-read-chunk-size-limit 2048M --vfs-cache-mode writes --dir-cache-time 96h --daemon

  2. 使用 df -h 檢查掛載點,也可以到 Synology File Station 查看。

參考:
Installation: 群暉 NAS 掛載 Google Drive 雲端共享硬碟(團隊盤) - ITW01
Config: Setting up rclone docker on Synology NAS to copy to Google Drive · ETdoFresh
Config: https://www.alenws.com/56797.html
Config (Make Google API keys on our own): Google drive
Config: [Nas] 如何在 Synology Nas 中使用 docker 並建立 rclone 來掛載資料夾 ? – CoLaBug.com