跳转到主要内容

ubuntu onedrive 配置用于同步keepass

安装

sudo apt install onedrive

授权

终端执行

[15:54] ~ ❯ onedrive

会输出:

Configuring Global Azure AD Endpoints
Authorize this app visiting:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=d50ca740-c83f-4d1b-b616-12c519384f0c&scope=Files.ReadWrite%20Files.ReadWrite.All%20Sites.ReadWrite.All%20offline_access&response_type=code&prompt=login&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient

Enter the response uri:

将连接复制,通过浏览器打开之后,会提示登录微软账号,登录之后,将地址栏的链接复制到终端,并回车。

同步

目前需求只同步密码

onedrive --synchronize --single-directory 'keepass' 

自动同步

添加配置文件

此步骤可选

sudo cp /usr/share/doc/onedrive/config ~/.config/onedrive/
# 修改权限
sudo chown $USER:$USER ~/.config/onedrive/config

添加同步列表

~/.config/onedrive/目录下,创建sync_list文件 添加内容:

# 同步密码
keepass

启动服务

systemctl enable --user onedrive

运行服务

systemctl start --user onedrive

查看服务状态

 systemctl status --user onedrive

重启服务

systemctl restart --user onedrive

停止服务

systemctl disable --now --user onedrive

查看实时log

journalctl --user-unit=onedrive -f

卸载

# 卸载应用
sudo apt remove --autoremove onedrive
# 清楚数据
rm -R ~/.config/onedrive

参考