• 欢迎访问db1024网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏db1024吧

Gdrive:Linux下谷歌网盘同步工具、自动备份VPS文件到Google Drive – Rat’s Blog

主机教程 Liam 1年前 (2019-04-27) 618次浏览 7个评论 扫描二维码
文章目录[隐藏]

简介

GdriveLinux下上传、下载Google Drive文件的一款CLI工具,安装简单、使用方便。

安装

centos 7下测试通过。
1、安装

wget -O /usr/bin/gdrive "https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA&export=download" chmod +x /usr/bin/gdrive 

2、授权

gdrive about 

然后会出现一串网址并询问验证码。
Gdrive:Linux下谷歌网盘同步工具、自动备份VPS文件到Google Drive - Rat's Blog
将地址粘贴到浏览器并登陆账号,会返回一串代码。
Gdrive:Linux下谷歌网盘同步工具、自动备份VPS文件到Google Drive - Rat's Blog
将代码粘贴到SSH下,然后会返回你的账户信息。
Gdrive:Linux下谷歌网盘同步工具、自动备份VPS文件到Google Drive - Rat's Blog
gdrive程序会自动将你的token保存在用户目录下的.gdrive目录中,所以如果不需要了记得把这个文件删掉。

使用

常用命令如下,更多查看gdrive官网:https://github.com/prasmussen/gdrive

1、列出Google Drive根目录下文件、文件夹

gdrive list 

2、下载Google Drive根目录下文件到本地(xxxx为文件名)

gdrive download xxxx 

3、下载Google Drive根目录下文件夹到本地(xxx为文件夹名)

gdrive download xxx 

4、把本地文件上传到Google Drive根目录下(xxxx为文件名)

gdrive upload xxxx 

5、在Google Drive根目录下创建文件夹(xxx为文件夹名)

gdrive mkdir xxx 

自动备份

1、网站自动备份脚本(基于Mysql数据库)
脚本下载:googledrive.sh
修改以下部分:

第3行:my-database-name改为自己的数据库名 第4行:my-database-user改为自己的数据库用户名 第5行:my-database-password改为自己的数据库用户名对应的密码 第7行:yourdomain.com改为自己的网站目录 第8行:/home/wwwroot改为自己的网站所在目录(即需备份目录为/home/wwwroot/yourdomain.com) 第9行:/backups改为备份文件存放目录 第35行:[email protected]修改为自己的邮箱 

2、更改权限

chmod +x googledrive.sh 

3、创建定时任务

vi  /etc/crontab 

添加

0 2 * * * /backups/googledrive.sh 

以上备份脚本存放在/backups/下,每日2点备份。

4、重启crontab

/etc/init.d/crond restart 

原文参考:Gdrive:Linux下同步Google Drive文件、自动备份网站到Google Drive


db1024 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Gdrive:Linux下谷歌网盘同步工具、自动备份VPS文件到Google Drive – Rat’s Blog
喜欢 (0)
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(7)个小伙伴在吐槽
  1. Pretty nice post. I just stumbled upon your weblog and wanted to say that I've truly enjoyed surfing around your blog posts. After all I'll be subscribing to your rss feed and I hope you write again soon!
    black mass2020-08-31 10:52 回复 Mac OS X | Chrome 53.0.2785.143
  2. Greetings from Los angeles! I'm bored to death at work so I decided to check out your website on my iphone during lunch break. I really like the info you provide here and can't wait to take a look when I get home. I'm surprised at how fast your blog loaded on my mobile .. I'm not even using WIFI, just 3G .. Anyhow, amazing site!
    black mass2020-08-28 23:04 回复 Mac OS X | Firefox浏览器 61.0
  3. Outstanding post however , I was wondering if you could write a litte more on this topic? I'd be very grateful if you could elaborate a little bit further. Many thanks!
    cheap flights2020-08-27 11:27 回复 Mac OS X | Chrome 67.0.3396.87
  4. Great blog here! Also your website loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as fast as yours lol 3aN8IMa cheap flights
    cheap flights2020-08-26 03:16 回复 Linux | Firefox浏览器 56.0.4
  5. I wanted to thank you for this very good read!! I absolutely enjoyed every little bit of it. I have got you book-marked to check out new things you post… 3aN8IMa cheap flights
    cheap flights2020-08-24 21:28 回复 Mac OS X | Chrome 67.0.3396.87
  6. Piece of writing writing is also a fun, if you know afterward you can write if not it is complicated to write.
    website host2020-08-14 10:49 回复 Linux | Chrome 56.0.2924.87
  7. Hello there! Do you use Twitter? I'd like to follow you if that would be ok. I'm undoubtedly enjoying your blog and look forward to new posts.
    web hosting providers2020-08-11 18:58 回复 Windows 8.1 | Firefox浏览器 60.0