Google Drive一键备份工具[linux命令行]

先安装gdrive ,然后利用API上传备份

#!/bin/sh

#wget -O /usr/bin/gdrive http://dl.lamp.sh/files/gdrive-linux-x64
#wget -O /usr/bin/gdrive http://dl.lamp.sh/files/gdrive-linux-386
#chmod +x /usr/bin/gdrive
#gdrive about

gdrive upload /home/admin/admin_backups/admin.root.admin.tar.gz

rm -rf  /home/admin/admin_backups/*

update 2018-04-01: gdrive增量备份方法

./gdrive sync upload --keep-remote 同步本地目录 远程目录ID
远程目录是下面这个ID形式的
1A-_AXmiTkrFEdTHVXhzdk6

常用查询语句

#查询文件名
gdrive list --query  " name contains 'htal' "
gdrive list --query  " fullText  contains 'htal' "
#查询根目录
gdrive list --query  "'root' in parents"
gdrive list --query  "'appDataFolder' in parents"
gdrive list --query " '1GKI97um7jxZRNPmR50rmDQ1RW0hiaPhA' in parents"
#查询MIME文件
gdrive list --query  " mimeType contains 'application/vnd.google-apps.folder'  "
#查询修改时间
gdrive list --query  "modifiedTime > '2018-04-04T12:00:00' "
gdrive list --query  "createdTime  > '2018-04-04T12:00:00' "

https://developers.google.com/drive/v3/web/search-parameters
https://github.com/prasmussen/gdrive

如果需要完全版本,请访问 https://teddysun.com/469.html

Leave a Comment