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

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

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