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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
PCI Perspectives
PCI Perspectives
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
量子位
博客园_首页
S
SegmentFault 最新的问题
S
Secure Thoughts
F
Full Disclosure
H
Hacker News: Front Page
博客园 - 三生石上(FineUI控件)
U
Unit 42
H
Heimdal Security Blog
N
News and Events Feed by Topic
A
About on SuperTechFans
C
CERT Recently Published Vulnerability Notes
Cyberwarzone
Cyberwarzone
Help Net Security
Help Net Security
The Hacker News
The Hacker News
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
罗磊的独立博客
N
News | PayPal Newsroom
Spread Privacy
Spread Privacy
C
Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
云风的 BLOG
云风的 BLOG
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
B
Blog
人人都是产品经理
人人都是产品经理
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
L
LINUX DO - 热门话题
Google Online Security Blog
Google Online Security Blog
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog RSS Feed

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个机房按小时计费,支持支付宝,【点击查看】。