前言
云服务器跑着各种项目,包括这个博客,所以数据文件相当重要,尤其运行那么多年,早期编写shell脚本定时备份到服务器指定地方,现在担心什么时候服务器也挂,于是想到自动备份到百度云盘.
环境
- centos7
- python2.7
步骤
- 修改pip源
vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
- 安装bypy
pip install bypy
- 执行
bypy info
- 正常输出
Please visit:
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&client_id=xxxxxxxxxxxxx&redirect_uri=oob&response_type=code
And authorize this app
Paste the Authorization Code here within 10 minutes.
Press [Enter] when you are done
复制网址到浏览器打开登录百度帐号绑定验证
登录后会得到百度授权码,复制到命令行确认(时间比较久,耐心等待)
Authorizing, please be patient, it may take upto 300 seconds...
Authorizing/refreshing with the OpenShift server ...
OpenShift server failed, authorizing/refreshing with the Heroku server ...
Successfully authorized
Quota: 20.020TB
Used: 560.023GB
常用命令
bypy list # 显示文档
bypy upload filename -v # 上传某文件,显示进度
bypy -c # 取消令牌文件。一段时间后要重新授权
bypy downdir filename # 下载
bypy compare # 比较本地目录和网盘目录
- 示例
bypy upload test.zip -v
bypy syncup mydir backup/mydir -v