使用bypy备份树莓派上的数据

由于我的个人博客和一些数据都是放在我家的一台树莓派上面的,所以数据安全备份就是一个急需要解决的问题。

bypy是一个由国人写的百度云Python客户端,写它的作者最初的目的就是为了备份树莓派的数据,巧了我也有这个需求,于是就选择了这个工具,该工具依赖Python,树莓派天生支持Python,所以是最友好的。

bypy的地址 https://github.com/houtianze/bypy

极简说明:

授权登陆:

执行 bypy info,显示下边信息,根据提示,通过浏览器访问下边灰色的https链接,如果此时百度网盘账号正在登陆,会出现长串授权码,复制。

pi@raspberrypi:~ $ bypy info
Please visit:
https://openapi.baidu.com/oauth/2.0/authorize?scope=basic+netdisk&redirect_uri=oob&response_type=code&client_id=q8WE4EpCsau1oS0MaqgMKNBn
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 infinite seconds...
Authorizing/refreshing with the OpenShift server ...
OpenShift server failed, authorizing/refreshing with the Heroku server ...
Successfully authorized
Quota: 3.112TB
Used: 967.930GB

测试同步:

由于百度PCS API权限限制,程序只能存取百度云/apps/bypy目录下面的文件和目录。我们可以通过:

pi@raspberrypi:~ $ bypy list
/apps/bypy ($t $f $s $m $d):

把本地当前目录下的文件同步到百度云盘:


pi@raspberrypi:~ $ sudo bypy upload

把云盘上的内容同步到本地:

pi@raspberrypi:~ $ sudo bypy downdir

比较本地当前目录和云盘根目录,看是否一致,来判断是否同步成功:

pi@raspberrypi:~ $ sudo bypy compare

标签:bypy, 树莓派, 备份