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

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

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