使用Fclone + iCopy 转存GoogleDrive

一、脚本安装Fclone

Fclone 作者mawaya

项目地址 https://github.com/mawaya/rclone

使用下面的脚本安装Fclone

bash <(wget -qO- https://git.io/JJYE0)

安装后如下图


二、使用Autorclone及Fclone设置google drive

转存需要用到AutoRclone生成accounts sa文件,如何生成及使用参考以下两个链接,写的非常详细

Use “AutoRclone + gclone” 教程 Copy GoogleDrive Resources Easy

Rclone 750G自动换号– AutoRclone使用教程

设置fclone

输入fclone config配置

root@ruvds-ab2cz:~# fclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config 
n/s/q>  n   #输入n新建
name> gdrive  #GD名字,随便写
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, 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 #输入13选择GoogleDrive<
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id 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
Google Application Client Secret
Setting your own is recommended.
Enter a string value. Press Enter for the default ("").
client_secret> #留空或者填写自己的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> 1  #选择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.

Note that if this is blank, the first time rclone runs it will fill it
in with the ID of the root folder.

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.
Enter a string value. Press Enter for the default ("").
service_account_file> #填写Autorclone生成的sa文件绝对路径,例如/root/Autorclone/accounts/xxx.json
Service Account Credentials JSON folder path.
Enter a string value. Press Enter for the default ("").
service_account_file_path> #填写Autorclone生成的sa文件夹路径,例如/root/Autorclone/accounts/
Edit advanced config? (y/n)
y) Yes
n) No (default)
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
y) Yes (default)
n) No
y/n> n #输入n
Please go to the following link
Log in and authorize rclone for access
Enter verification code> #输入获取到的code
Configure this as a team drive?
y) Yes
n) No (default)
y/n> y #输入y,配置为团队盘
Fetching team drive list...
Choose a number from below, or type in your own value
 1 / 的共享盘
   \ "0AJeA0p4"
 2 / 我的团队盘
   \ "0AEA8O4OO"
 3 / gdtest
   \ "0AHqG_8_VA"
Enter a Team Drive ID> 3 #选择要挂载的团队盘ID
--------------------
[gdrive]
type = drive
client_id = 
client_secret = 
scope = drive
token = {"access_token":"ya29","token_type":"Bearer","refresh_token":"1//0ccD","expiry":"2020-07-18T22:43:33.57345734+03:00"}
team_drive = 0AHqG_8_V
--------------------
y) Yes this is OK (default)
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退出

挂载团队盘,新建本地文件夹,路径自己定,即下面的LocalFolder

#挂载为磁盘,下面的DriveName、Folder、LocalFolder参数根据说明自行替换
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

回车后shell会卡住,关掉重新打开shell

df -h 命令可以看到挂载上了,1.0P容量

#如果要卸载磁盘使用以下命令
fusermount -qzu LocalFolder

设置开机启动(开机启动部分我未设置,抄自Rat's Blog)

先新建systemd配置文件,适用CentOS 7Debian 8+Ubuntu 16+

再使用命令:

#将后面修改成你上面手动运行命令中,除了rclone的全部参数
command="mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000"
#以下是一整条命令,一起复制到SSH客户端运行
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target

[Service]
Type=simple
ExecStart=$(command -v rclone) ${command}
Restart=on-abort
User=root

[Install]
WantedBy=default.target
EOF

开始启动:

systemctl start rclone

设置开机自启:

systemctl enable rclone

其他命令:

重启:systemctl restart rclone
停止:systemctl stop rclone
状态:systemctl status rclone

如果你想挂载多个网盘,那么将systemd配置文件的rclone.service改成rclone1.service即可,重启动什么的同样换成rclone1


三、docker安装mongodb

先安装好docker,复制整个然后粘贴全部,下面的username和password可以自己替换,配置iCopy的时候需要用到

docker run --network host --name icopy \
     -e MONGO_INITDB_ROOT_USERNAME=test \
     -e MONGO_INITDB_ROOT_PASSWORD=testtest \
     -d mongo:4.2.8


四、下载配置iCopy

iCopy 作者fxxkrlab,项目github地址 https://github.com/fxxkrlab/iCopy

git clone下载iCopy源码 (目前最新)

git clone https://github.com/fxxkrlab/iCopy.git

复制配置文件

cp iCopy/config/conf.toml.example iCopy/config/conf.toml

更改配置文件

vim /root/iCopy/config/conf.toml
[tg]

token = "Bot API Token HERE" # 在TG中 @botfather 获取机器人token

usr_id = "user id HERE" # 在TG中@get_id_bot获取自己TG的ID

[database]

db_connect_method = "mongodb" # like "mongodb", "mongodb+srv",etc...使用本机则填写mongodb,使用mondo free的填写mongodb+srv

db_addr = "localhost" # mongodb host address 使用mondo free的填写cluster0.xxx.gcp.mongodb.net/<dbname>?retryWrites=true&w=majority

db_port = 27017 # mongodb connect port,default is 27017

db_name = "iCopy" # 默认是 "iCopy"

db_user = "test" # 数据库的用户名,d

db_passwd = "testtest" # 数据库密码

[general]

language = "cn" # cn / eng / jp,default is "cn"

cloner = "fclone" # Only fclone is suitable now,Future supports: rclone / gclone / autorclone

option = "copy" # cloner option,e.g. "copy" , "sync"

remote = "gdrive" # 第二步中设置的googledrive 名字,我的是gdrive

parallel_c = "16" # checkers_NUM,default = "16" 越大越快

parallel_t = "32" # transfers_NUM,default = "32" 越大越快

min_sleep = "1ms" # customize drive-pacer-min-sleep,default = "1ms"

sa_path = "/root/accounts" #Service_Accounts 路径,结尾不加/,默认 "/root/accounts"

run_args = ['--drive-server-side-across-configs', '-P', '--stats=1s', '--log-level=DEBUG', '--log-file=/root/icopy_cloner_debug.log'] # status flags

确认自己VPS上的python版本大于3.6,新建一个iCopy screen

screen -S iCopy

安装python虚拟环境,进入虚拟环境,可以避免些问题,也可以不安装

apt-get install python3-venv

执行下面两条命令创建激活虚拟环境

python3 -m venv .
. ./bin/activate

安装需要的模块

pip3 install -r requirements.txt

如果报缺少wheel模块可以使用pip3 install wheel命令安装wheel,然后再次执行上面的依赖安装

所有模块安装完成后运行iCopy.py 启动

启动成功后可以ctr+A然后按D 切换回原来的screen,这样iCopy就在后台运行了

在机器人中输入/set quick+ 目录ID 或者/set fav+目录ID 设置转存目录,之后输入/start开始选择模式使用

最后输入要转存的资源链接或ID开始转存


五、iCopy的一些命令

根命令列表:
set - customize settings  
    ┖ set - batch way  
    ┖ set rule - rules  
    ┖ fav|quick +/- id - single way  
    ┖ set purge - purge favorites  
size - size query
    ┖ size - size the shared resource  
    ┖ size id - size specified task  
    ┖ size fav - size specified favorites  
task - task query  
    ┖ task - task in processing  
    ┖ task list - future 10 tasks  
    ┖ task id - show the specified task
reset - restore task  
    ┖ reset - restore current task  
    ┖ reset id  - restore the specified task 

结束

设置Fclone部分来自Rat's Blog

链接:https://www.moerats.com/archives/481/

设置mongodb和icopy部分来自 https://bbs.jsu.net/t/topic/171

最后编辑:2020年07月26日 ©著作权归作者所有

发表评论