跨平台 同步 & 备份 方案

27

1. 文档同步方案 - wolai & halo

  • 暂定使用 wolai & halo 的原因
    • wolai 方案虽然无本地,但为大厂方案,包含时间线功能,方便在多设备使用
    • halo 方案为公开文档展示,适用于博客类内容,与 wolai 相互承接
  • 其他备选方案
    • 语雀:可学生认证免费使用高级版,功能较少,不太符合功能要求
    • 飞书:飞书免费版基本够用,但是感觉比较冗余
    • flowus:无限块,但是无本地、需付费,不确定平台能否一直坚持下去
    • obsidian 结合 git 使用:此方案时间成本较高,可后续留作备用
    • trilium:私有文档方案,担心自己的服务器稳定性不足,暂未使用

2. 文件同步&备份方案

私有方案需要一个 24h 开机的中间服务,由于需求暂时不是很大,仅做调研,不实际开展

2.1. 私有同步

2.1.1. syncthing

网页形式
官网为英文,但部署后可选中文
官方网站:https://syncthing.net/
本地部署后地址:http://127.0.0.1:8384/#

2.1.2. resilio - 待尝试

客户端形式 - 无中文
本地部署后地址:http://127.0.0.1:8888/gui/

2.1.3. 微力同步

国产版本
官方网站:http://www.verysync.com/

2.2. 私有备份

kopia

https://kopia.io/

2.3. OneDrive 方案

经过测试以下挂载方案,由于在深度系统上的稳定性表现不太好,具体表现为:网络不稳定时导致文件管理器卡顿无法正常操作,且配置十分繁琐

Deepin 系统下的 OneDrive 的同步方案暂时不用了

使用小主机上 win10 系统下的 onedrive

2.3.1. win10 官方

使用小主机上 win10 系统下的 onedrive 进行文件同步,其他 OneDrive 方案已经不再使用。

2.3.2. (不再使用)rclone

  1. 使用脚本安装 rclone
sudo -v ; curl https://rclone.org/install.sh | sudo bash
  1. GUI 可视化页面测试配置 OneDrive 以及挂载
# 可给存储取名 bayminOneDrive
# https://rclone.org/gui/
rclone rcd --rc-web-gui
  1. 运行
# 官方挂载文档:https://rclone.org/commands/rclone_mount/
# 使用标志 --daemon 强制进入后台模式
# 示例:rclone mount remote:path/to/files /path/to/local/mount
# 先测试以下能否正常挂载
rclone mount bayminOneDrive:/ /home/baymin/OneDrive
# 测试能够正常挂载后 加入后台模式参数
rclone mount bayminOneDrive:/ /home/baymin/OneDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-non-empty --umask 000 --daemon
# 在后台模式下运行时,用户需要手动停止挂载
# 示例:fusermount -u /path/to/local/mount
fusermount -u /home/baymin/OneDrive
  1. 配置开机自启
    创建配置文件
# --allow-other:指的是允许非当前Rclone用户外的用户进行访问

以下是一整条命令,一起复制到SSH客户端运行

sudo cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Mount /opt/movie using rclone
After=network-online.target

[Service]
Type=forking
# 将 ExecStart 修改成你上面手动运行命令的全部内容
ExecStart=rclone mount bayminOneDrive:/ /home/baymin/OneDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-non-empty --umask 000 --daemon
ExecStop=fusermount -u /home/baymin/OneDrive
Restart=on-failure
RestartSec=10
User=baymin

[Install]
WantedBy=default.target
EOF

以下命令需要在修改上述配置文件后才能执行

# 开机自启
systemctl enable rclone
# 关闭开机自启
systemctl disable rclone
# 启动
systemctl start rclone
# 重启
systemctl restart rclone
# 停止
systemctl stop rclone
# 查看运行状态
systemctl status rclone
  1. 卸载
# Rclone卸载命令
sudo rm /root/.config/rclone/rclone.conf

# 要删除 rclone 命令和手册页,只需按照以下命令删除文件
sudo rm /usr/bin/rclone
sudo rm /usr/local/share/man/man1/rclone.1
参考链接

https://zhuanlan.zhihu.com/p/355431169
https://www.yunieebk.com/rclone_auto_mount/

2.3.3. (不再使用)abraunegg/onedrive

命令行版 - 较为繁琐 - 有被清空风险

安装 - 方法1
  1. 首先通过 deepin 自带的应用商店安装星火应用商店
  2. 星火应用商店中搜索 onedrive 进行安装
安装 - 方法2

https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md
a.依赖

sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev
sudo snap install --classic dmd

b.安装

git clone https://github.com/abraunegg/onedrive.git
cd onedrive
./configure
make clean; make;
sudo make install

c.卸载

sudo make uninstall
# delete the application state
rm -rf ~/.config/onedrive
配置
  1. 命令行输入 onedrive 进行认证
[user@hostname ~]$ onedrive 
Authorize this app visiting:

Enter the response uri:
Application has been successfully authorised, however no additional command switches were provided.

Please use --help for further assistance in regards to running this application.
  1. 创建配置文件
mkdir -p ~/.config/onedrive
# cp ./config ~/.config/onedrive/config
vim ~/.config/onedrive/config
  1. 自定义同步规则
    https://raw.githubusercontent.com/abraunegg/onedrive/master/config
# Directory where the files will be synced
# 设置同步文件夹位置
sync_dir = "/persistent/home/baymin/OneDrive"
# Skip files and directories that match this pattern
# 自定义哪些文件不被同步,这里是双向的,本地和云端都生效(本地的不会上传,云端的不会下载)
skip_file = "~*|.~*|*.tmp"
# 自定义哪些文件夹不被同步,这里是双向的,本地和云端都生效(本地的不会上传,云端的不会下载)
skip_dir = "/1Panel/*|/aeLearning/*|/bt_backup/*|/Desktop/*|/Downloads/*|/GoodNotes/*|/Music/*|/Notability/*|/Pictures/*|/Videos/*|/应用/*|/文档/*"
# 忽略所有隐藏文件和文件夹
skip_dotfiles = "true"

注意: 修改配置文件后都需要执行一遍 onedrive --synchronize --resync

  1. (可选)指定需要同步的文件和文件夹
    客户端默认会下载 OneDrive 云端所有文件,通过创建文件 sync_list,指定需要同步的文件和文件夹。
cd ~/.config/onedrive
vim sync_list

~/.config/onedrive 下创建文件 sync_list,文件内容示例如下:

/Visio/
  1. 测试配置文件
    onedrive --synchronize --verbose --dry-run
    其中--dry-run 不会改变本地或云端的任何文件,终端输出的是“将要发生的情况”。
运维

手动运行

onedrive --synchronize

自动运行

systemctl --user enable onedrive
systemctl --user start onedrive

查看日志

journalctl --user-unit onedrive -f
备注

参考链接:https://zhuanlan.zhihu.com/p/372355859
GitHub仓库链接:https://github.com/abraunegg/onedrive

2.3.4. (不再使用)OneDriver

https://github.com/jstaf/onedriver
git clone https://github.com/jstaf/onedriver.git
make