惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

Rat's Blog - Gdrive

Windows和Linux VPS/GDrive之间文件夹的实时单向/双向同步教程 - Rat's Blog Filestash:一个多功能的Web端文件管理器,支持SFTP/GDrive/Dropbox/S3等 - Rat's Blog
Gdrive:Linux下谷歌网盘同步工具、自动备份VPS文件到Google Drive - Rat's Blog
博主: Rat's · 2017-09-14 · via Rat's Blog - Gdrive
  •  发布时间:
  •  30459 次浏览
  •   10 条评论
  •  1768 字数
  • 分类: 建站知识
  1.  首页
  2. 正文  
  3. 分享到:

简介

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

然后会出现一串网址并询问验证码。
请输入图片描述
将地址粘贴到浏览器并登陆账号,会返回一串代码。
请输入图片描述
将代码粘贴到SSH下,然后会返回你的账户信息。
请输入图片描述
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行:youremail@yourdomain.com修改为自己的邮箱

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


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/296/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。