gclone实现google drive不同账户及目录间的转存(非链接)

关于gclone

gclone是Rclone的修改版本 为Google驱动器操作提供动态替换sa文件支持。由于rclone在对google drive操作上存在一定的不方便性。所以就出现了gclone这个东西。由于本人的空间已经存满,同时很多资源失效也快,需要及时备份,就尝试了一下感觉还不错。由于现在很多GD的资源转存过来的时候已被替换成超级链接,好处是不占空间,坏处是原拥有者删除或关闭共享,你就用不了了。为了摆脱这种依赖性,最好能将拥有者的文件直接拷贝到自己的名下。原理是先用Rclone挂载好google drive(一个或多个)—将转载来的资源(团队盘)通过gclone直接copy到自己用户下,实现本机盘存储。其中gclone支持目录ID拷贝,避免了团队盘管理员的依懒性。目前利用gclone已经可以突破每天750G流量的限制。

#相关项目地址
https://github.com/xyou365/AutoRclone
https://github.com/Spazzlo/folderclone
https://github.com/donwa/gclone

《gclone实现google drive不同账户及目录间的转存(非链接)》

Rclone

此章非必须,如果你对gclone非常不熟悉,或者认为自己动手能力极差的同时,你竟然对rclone非常熟悉,那么你可以先用Rclone挂载下。这里就不多做介绍了,前提条件就是已经使用rclone挂载了gd可以参考这里利用Rclone挂载Google Drive。多账户挂载多配置几个conf文件即可。挂载好了可直接跳到最后看实例。注意此处是非必须的,你也可以直接用gclone直接挂载。

安装调试

以centos7作为运行系统,其他系统未测试。

安装wget

yum install wget

安装Gclone

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

安装成功后运行gclone,测试安装是否成功,得到命令如下

# gclone
Usage:
  rclone [flags]
  rclone [command]

Available Commands:
  about           Get quota information from the remote.
  authorize       Remote authorization.
  cachestats      Print cache stats for a remote
  cat             Concatenates any files and sends them to stdout.
  check           Checks the files in the source and destination match.
  cleanup         Clean up the remote if possible
  config          Enter an interactive configuration session.
  copy            Copy files from source to dest, skipping already copied
  copy            Copy files from source to dest, skipping already copied
  copyto          Copy files from source to dest, skipping already copied
  copyurl         Copy url content to dest.
  cryptcheck      Cryptcheck checks the integrity of a crypted remote.
  cryptdecode     Cryptdecode returns unencrypted file names.
  dbhashsum       Produces a Dropbox hash file for all the objects in the path.
  dedupe          Interactively find duplicate files and delete/rename them.
  delete          Remove the contents of path.
  deletefile      Remove a single file from remote.
  genautocomplete Output completion script for a given shell.
  gendocs         Output markdown docs for rclone to the directory supplied.
  hashsum         Produces an hashsum file for all the objects in the path.
  help            Show help for rclone commands, flags and backends.
  link            Generate public link to file/folder.
  listremotes     List all the remotes in the config file.
  ls              List the objects in the path with size and path.
  lsd             List all directories/containers/buckets in the path.
  lsf             List directories and objects in remote:path formatted for parsing
  lsjson          List directories and objects in the path in JSON format.
  lsl             List the objects in path with modification time, size and path.
  md5sum          Produces an md5sum file for all the objects in the path.
  mkdir           Make the path if it doesn't already exist.
  mount           Mount the remote as file system on a mountpoint.
  move            Move files from source to dest.
  moveto          Move file or directory from source to dest.
  ncdu            Explore a remote with a text based user interface.
  obscure         Obscure password for use in the rclone.conf
  purge           Remove the path and all of its contents.
  rc              Run a command against a running rclone.
  rcat            Copies standard input to file on remote.
  rcd             Run rclone listening to remote control commands only.
  rmdir           Remove the path if empty.
  rmdirs          Remove empty directories under the path.
  serve           Serve a remote over a protocol.
  settier         Changes storage class/tier of objects in remote.
  sha1sum         Produces an sha1sum file for all the objects in the path.
  size            Prints the total size and number of objects in remote:path.
  sync            Make source and dest identical, modifying destination only.
  touch           Create new file or change file modification time.
  tree            List the contents of the remote in a tree like fashion.
  version         Show the version number.

Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.

查看下程序及环境版本

#查看版本
gclone version
#版本输出
rclone v1.51.0-mod1.3.1
- os/arch: linux/amd64
- go version: go1.13.8
#注意,go的版本可能有限制,目前我没测试

由于是一键脚本,所以安装路径并不清楚,非必须

#查下gclone的安装路径
which gclone
#我的安装路径为
/usr/bin/gclone

程序配置

参考这里利用Rclone挂载Google Drive。如果你要在不同账户的google盘,并且其中被拷贝的目录不共享,那么你就需要配置多个账户的conf文件!否则是无权限操作的。

配置gclone,如果已经配置了rclone,这里可以忽略了。命令基本和rclone一样,就是在命令前面多加了个g,命令由原来的rclone变成了grclone

#配置网盘挂载配置文件
gclone config

下面和Rclone配置一样。

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>n #没有就新建一个输入n

给配置文件输入名称,不限制

name> kkk

选好你的驱动器之后,下面一路默认,到最后选否,手动去授权填入code即可。基本和rclone一样。

文件转存

速度非常快啊,我的大概10G文件,5秒左右吧。用的是PR的VPS。

使用命令。

gclone copy g1s:{1qMBhAIjgQKTp-Eitxs0k1pHpeZrTNjZI} g1s:{1q2696hdHYcD4EimOBVvq4BpM-EhzPlOE}  --drive-server-side-across-configs

其中
1qMBhAIjgQKTp-Eitxs0k1pHpeZrTNjZI只指的是别人团队盘或者共享盘的目录ID
1q2696hdHYcD4EimOBVvq4BpM-EhzPlOE指的是你自己GD的目录ID

目录ID指的是,你打开文件夹后蓝色的部分
https://drive.google.com/drive/u/1/folders/1q2696hdHYcD4EimOBVvq4BpM-EhzPlOE

《gclone实现google drive不同账户及目录间的转存(非链接)》

注意:运行的时候有点小卡,没有进度条提示的缘故。不费本机流量、不费本机流量、不费本机流量!

多个驱动器之间互传示例

gclone copy g1s:{1qMBhAIjgQKTp-Eitxs0k1pHpeZrTNjZI} g2s:{1q2696hdHYcD4EimOBVvq4BpM-EhzPlOE}  --drive-server-side-across-configs

其中g1s为网盘1配置名,g2s为网盘2配置名,替换成你自己的即可。

ondedrive拷贝到google

rclone copy -P od:abc gd:abc --ignore-errors --stats-one-line

service_account_file_path配置

添加service_account_file_pathConfiguration.For动态替换service_account_file(一个文件)。rateLimitExceeded发生错误时 替换配置rclone.conf示例:

/root/accounts/文件夹包含多个访问和编辑权限服务帐户文件( .json) *。

[g1s]
type = drive  
scope = drive  
service_account_file = /root/accounts/1.json  
service_account_file_path = /root/accounts/  
root_folder_id = root

点赞

发表评论