使用rclone将文件同步至Google Dirve
昨日在某途径购买了一个Gsuite教育版的子账户,账户所属是一个国际性的社会大学,搞到账户之后网上找了一圈发现很少在centos下挂载的方法,hostloc上的小伙伴提示使用rclone可以挂载,但是网上几乎只找到那复制粘贴无数遍的添加网盘方法,无奈自己研究,目前还没实现挂载,只发现了如何将文件同步到Google Dirve.
注意,普通的Google Dirve只有15G,含Google Dirve无限容量的Gsuite套餐只有Business,Enterprise,edu这三个了,Business价格是1200円/月,Enterprise是定制版价格不一,相比之下还是想办法搞一个edu账户划算.
下面开始讲rclone安装和同步方法,首先Google Dirve账户一个,rclone文件一份,linux机器一个(以centos7为例),然后开始安装rclone,安装很简单,复制粘贴加权限等.
首先是下载文件
yum install unzip wget -y wget -O https://downloads.rclone.org/rclone-current-linux-amd64.zip unzip rclone-current-linux-amd64.zip cd rclone-*-linux-amd64
然后复制文件到相关路径
cp rclone /usr/bin/
chown root:root /usr/bin/rclone
chmod 755 /usr/bin/rclone
安装帮助页(此步骤可以省略,但省略之后没有一些提示,不推荐省略)
mkdir -p /usr/local/share/man/man1
cp rclone.1 /usr/local/share/man/man1/
mandb
然后我们新建一个配置
rclone config
下面是直接在官网copy的添加Google Dirve的过程
n) New remote
d) Delete remote
q) Quit config
e/n/d/q> n
name> shira(你的配置名称,此处随意填写但之后需要用到)
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Amazon Drive
\ "amazon cloud drive"
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
\ "s3"
3 / Backblaze B2
\ "b2"
4 / Dropbox
\ "dropbox"
5 / Encrypt/Decrypt a remote
\ "crypt"
6 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
7 / Google Drive
\ "drive"
8 / Hubic
\ "hubic"
9 / Local Disk
\ "local"
10 / Microsoft OneDrive
\ "onedrive"
11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
12 / SSH/SFTP Connection
\ "sftp"
13 / Yandex Disk
\ "yandex"
Storage> 7(根据网盘类型选择Google Dirve)
Google Application Client Id - leave blank normally.
client_id>此处留空
Google Application Client Secret - leave blank normally.
client_secret>此处留空
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?xxxxxxxxxxxxxxxxx
Log in and authorize rclone for access
Enter verification code>xxxxxxxxxxx(将上面给出的url复制到你的浏览器打开,登录你的Google Dirve所在的google账户,然后将得到的一串字符串粘贴到此处)
--------------------
[shira]
client_id =
client_secret =
token = {"AccessToken":"xxxx.x.xxxxx_xxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","RefreshToken":"1/xxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxx","Expiry":"2014-03-16T13:57:58.955387075Z","Extra":null}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y(确定信息并保存)
网上大多数"教程"到这里就没有了,下面是在官网找到的一些操作和同步方法
列出文件和目录
rclone lsd shira: #列出配置名为shira的网盘的目录(不会显示文件)
rclone ls shira:anime #列出配置名为shira的网盘里anime目录下的文件(会显示包括子目录内的所有文件不显示目录)
文件和目录的复制剪切删除操作
rclone copy /root/anime shira:anime #复制本地/root/anime到配置名为shira的网盘的anime目录,反过来也可以
rclone move /root/anime shira:anime #剪切操作
rclone delete shira:anime #删除配置名为shira的网盘的anime目录
rclone mkdir shira:anime #创建配置名为shira的网盘的anime目录
同步文件
rclone sync /root/anime shira:anime#同步本地/root/anime到配置名为shira的网盘的anime目录,反过来也可以
rclone sync shira2:donga shira:anime #同步本地配置名为shira2的网盘的donga目录到配置名为shira的网盘的anime目录,反过来也可以
其实用到的操作官网几乎都有,其它需要可以在官网看.
同步的时候最好要在后面加--dry-run命令,不然它会删除该目录下的文件,我就吃了很大的亏。一个T的文件传了一个多礼拜。最后发现不对劲,回收站一批文件。
rclone 直接看mount的子页面就可以了啊。。。。
不过mount体验不算很好就是,cache区如果被塞满了就会报IO ERROR
这个后来知道了,但是google的api限制访问频次,频繁访问就会造成io错误