Ubuntu使用OneDrive实现本地文件自动同步

1 安装

sudo add-apt-repository ppa:yann1ck/onedrive
sudo apt-get update
sudo apt-get install onedrive

2 授权

执行onedrive然后按照提示进行登录,授权

3 配置

我的需求是,只同步根目录下的,其他子目录都不用

vim ~/.config/onedrive/config

# Configuration for OneDrive Linux Client
# This file contains the list of supported configuration fields
# with their default values.
# All values need to be enclosed in quotes
# When changing a config option below, remove the '#' from the start of the line
# For explanations of all config options below see docs/USAGE.md or the man page.
#
# sync_dir = "~/OneDrive"
# skip_file = "~*|.~*|*.tmp"
# monitor_interval = "300"
# skip_dir = "/*"
# log_dir = "/var/log/onedrive/"
# drive_id = ""
# upload_only = "false"
# check_nomount = "false"
# check_nosync = "false"
# download_only = "false"
# disable_notifications = "false"
# disable_upload_validation = "false"
# enable_logging = "false"
# force_http_11 = "false"
# force_http_2 = "false"
# local_first = "false"
# no_remote_delete = "false"
# skip_symlinks = "false"
# debug_https = "false"
# skip_dotfiles = "false"
# dry_run = "false"
# min_notify_changes = "5"
# monitor_log_frequency = "5"
# monitor_fullscan_frequency = "10"
# sync_root_files = "false"
# classify_as_big_delete = "1000"
# user_agent = ""
# remove_source_files = "false"
# skip_dir_strict_match = "false"
# application_id = ""
# resync = "false"
# bypass_data_preservation = "false"
# azure_ad_endpoint = ""
# azure_tenant_id = "common"
# sync_business_shared_folders = "false"

添加同步文件夹白名单

vim ~/.config/onedrive/synclist
upload

4 试运行

onedrive --synchronize --verbose --dry-run

5 设置开机自启动

systemctl --user enable onedrive
systemctl --user start onedrive
# 停止
systemctl --user stop onedrive

日志位置在这里/var/log/onedrive/,需要自己创建并给权限

Leave a Reply

Your email address will not be published.