[f44] 使用 Rclone 同步 Onedrive 上的 home 文件夹(放弃)
01 Mar, 2026 12:00 AM +00:00
Part 1. 初始化工作
首次同步前,先做这些:
1. 安装 Rclone CLI
rpm-ostree install rclone
flatpak 太麻烦,这里直接安装到了 rpm-ostree 。
2. 初始化 Rclone 的 Onedrive 配置文件
clone config
然后跟着交互式工具走,注意 remote 的 name 这里是 onedrive8614 。
3. 写一个 systemd 脚本,实现自动同步
创建模板 Service 文件:
# ~/.config/systemd/user/rclone-sync@.service
[Unit]
Description=Rclone bisync for %i
After=network-online.target
[Service]
Type=oneshot
# %i 是一个占位符,代表你在启动时传入的名字
ExecStart=/usr/bin/rclone bisync %h/%i onedrive8614:%i --progress
编写 Timer 文件,每 5 分钟执行一次同步:
# ~/.config/systemd/user/rclone-sync@.timer
[Timer]
OnUnitActiveSec=5min
Unit=rclone-sync@%i.service
[Install]
WantedBy=timers.target
至此,初始化的工作结束了,可以看看 Part 2 。
Part 2. 添加要同步的文件夹
1. 初始化目标文件夹
rclone bisync ~/Videos onedrive8614:Videos --resync --progress
rclone bisync ~/Documents onedrive8614:Documents --resync --progress
rclone bisync ~/Pictures onedrive8614:Pictures --resync --progress2. 手动同步
rclone bisync ~/Videos onedrive8614:Videos3. 启用自动同步
# 启动视频同步
systemctl --user enable --now rclone-sync@Videos.timer
# 启动文档同步
systemctl --user enable --now rclone-sync@Documents.timer
# 启动图片同步
systemctl --user enable --now rclone-sync@Pictures.timer