玩转 Google Drive —— rclone 资源转存

记录一下使用过程。

Update 2019.5.30 一些其他玩法 (这是倒序,欢迎交流)

1. 如果要配置300个账号怎么弄呢?为了方便,可以在 Windows 主机上用下面的脚本进行配置,后面配置文件 rclone.conf 复制到别的地方也可以用。
for /L %%G in (1,1,300) do rclone config create c%%G drive --drive-client-id "xxx.apps.googleusercontent.com" --drive-client-secret "yyy" --drive-team-drive zzz
配置文件的位置可以输入命令 rclone config file 获得

2. 手上有 rclone.conf 文件,想从普通盘换到团队盘: 直接修改 rclone 的配置文件,给对应的盘加上 team_drive = YourTeamdriveID。同理换成别的团队盘直接修改 YourTeamdriveID 即可。

3. 为了更快完成任务,想将官方的 client id 换成自己的:直接在配置文件加 client_id = YourClientID 和
client_secret = YourClientSecret 两行。但是 token 还需再登陆认证来刷新一下…

交互式的安装步骤记录如下:

Step 1. 安装 rclone:
curl https://rclone.org/install.sh | sudo bash

Step 2. 参照 官方安装指南,配置rclone。
1. 输入 rclone config
2018/12/25 17:19:22 NOTICE: Config file “/root/.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

2. 输入 n,给新的远程配置起一个名字
name> cody_gd1
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 Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
\ “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 / Mega
\ “mega”
17 / Microsoft Azure Blob Storage
\ “azureblob”
18 / Microsoft OneDrive
\ “onedrive”
19 / OpenDrive
\ “opendrive”
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ “swift”
21 / Pcloud
\ “pcloud”
22 / QingCloud Object Storage
\ “qingstor”
23 / SSH/SFTP Connection
\ “sftp”
24 / Webdav
\ “webdav”
25 / Yandex Disk
\ “yandex”
26 / http Connection
\ “http”
Storage>

3. 选择 Google Drive,输入数字 12
Storage> 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 (“”).

4. 用 rclone 的 client_id,直接回车
client_id> 回车
Google Application Client Secret
Setting your own is recommended.
Enter a string value. Press Enter for the default (“”).

5. 用 rclone 的 client_secret,直接回车+1
client_secret> 回车
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>

6. 直接回车+2
scope> 回车
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>

7. 直接回车+3
root_folder_id> 回车
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>

8. 直接回车+4
root_folder_id> 回车
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>
Edit advanced config? (y/n)
y) Yes
n) No
y/n>

9. 不编辑高级设置,输入 n
y/n> n
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n>

10. 输入 n(如果是本地安装了浏览器的电脑可以输入y
y/n> n
If your browser doesn’t open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=202264815744.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=a5409d63a4b6d0063b3e1bf1336261eb
Log in and authorize rclone for access
Enter verification code>

11. 复制上链接到浏览器,获得如下形式的 verification code
Enter verification code> 4/fAFDoVQlYzfEsHo0jjWSxXiINSID21yKS3M51hNFeNuH2gyc7t1ebR4
Configure this as a team drive?
y) Yes
n) No
y/n>

12. 输入n(如果是团队盘输入y)
y/n> n
——————–
[cody_gd1]
type = drive
token = {“access_token”:”ya29.Gls7B3xW0QneoaH-BKfvbsIJCe7IQuR9Qxq3IHisgSmRfNLhB1o52O2SuY31Lu2VCjr5mX5FIz0cklE5iG16sybT0uY5PPYGI6n6YjZ5xSCGfgV85aSMi8M0aRlk”,”token_type”:”Bearer”,”refresh_token”:”1/ck-ig6X4lf7ql3eX0bqH3ZB0HHpGAccRdGUpf4rV80Y”,”expiry”:”2019-07-05T02:24:16.733118566+08:00″}
——————–
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d>

13. 输入y
y/e/d> y
Current remotes:

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

14. 输入q
e/n/d/r/c/s/q> q
完成账号配置。再检查配置:
[email protected]:~# rclone lsd cody_gd1:
-1 2018-09-13 20:18:10 -1 Colab Notebooks
-1 2017-12-25 20:05:27 -1 Google Photos
-1 2018-02-16 14:27:57 -1 IFTTT
-1 2018-02-05 01:00:06 -1 Music
-1 2018-11-13 11:15:12 -1 周杰伦全集
-1 2018-10-16 15:03:37 -1 王菲合集
成功读取Google Drive根目录,配置成功。

Step 3. 开始copy
rclone copy -P cody_gd1:周杰伦全集 cody_gd1:周杰伦全集_copy
将别人共享的“周杰伦全集”复制一份为“周杰伦全集_copy”
经过漫长的等待,终于拷贝完成。检查拷贝是否完全:
rclone check cody_gd1:周杰伦全集 cody_gd1:周杰伦全集_copy
又经过漫长的等待:
2019/07/05 01:52:36 NOTICE: Google drive root ‘cody_gd1:周杰伦全集_copy’: 0 differences found
2019/07/05 01:52:36 NOTICE: Google drive root ‘cody_gd1:周杰伦全集_copy’: 1024 matching files
拷贝完全。

后记丢失 ==大写的尴尬== 后续补充

说点什么

avatar
  Subscribe  
Notify of