nas-docker使用rsync备份重要文件

因为 nas 没做 raid 啥的, 所以一旦硬盘损坏里面的数据 GG了. 所以开始做点重要数据的备份比较放心.
数据备份用 增量备份 比较靠谱, 不必每次都全量备份. 所以就使用 rsync.
nas 是 qnap 牌子. 里面的 docker 不支持挂载 移动硬盘, 所以就在别的机子上搞 rsync 客户端


前篇


思路

  1. nas 上的 docker 起一个 Ubuntu 实例, 并挂载上需要同步的目录

  2. Ubuntu 实例开启 rsync 服务

    参考: 启动 rsync 服务可以参考: rsync同步文件 - https://blog.csdn.net/yangxuan0261/article/details/72676450

  3. win10 中开启子系统 Ubuntu

    参考: others-Win10子系统Ubuntu - https://blog.csdn.net/yangxuan0261/article/details/90161332

  4. 子系统 Ubuntu 挂载上移动硬盘

  5. 子系统 Ubuntu 中执行 rsync 同步命令

进一步扩展

在 vscode 写个插件, 集成 rsync 同步, 将 ip/port/user/local remote dir 等参数提取出来动态配置


测试 win10 中 Ubuntu 中的 rsync

本地测试

  1. H:\Picture 备份到 I:\test_bak

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    yangx@wilker:~$ sudo rsync -rt --verbose /mnt/h/Picture /mnt/i/test_bak
    sending incremental file list
    Picture/
    Picture/壁纸/
    Picture/壁纸/02171_romanticcottage_2560x1440.jpg
    Picture/壁纸/02171_romanticcottage_2560x1440_black.jpg
    ...
    sent 198,661,515 bytes received 2,533 bytes 132,442,698.67 bytes/sec
    total size is 198,604,513 speedup is 1.00
    yangx@wilker:~$
  2. 再执行几次相同的命令, 因为是增量备份, 所以会瞬间完成.