创建存储库

docker run -it --rm \
    -v /mnt/disk/backupData/restic-repo:/srv/restic-repo \
    -e RESTIC_REPOSITORY='/srv/restic-repo' \
    -e RESTIC_PASSWORD="pass" \
    restic init

备份数据

https://restic.readthedocs.io/en/latest/040_backup.html

restic不带定时备份功能,需要通过其他方式实现(crontab,systemctl等)

docker run -it --rm \
    -v /mnt/disk/backupData/restic-repo:/srv/restic-repo \
    -v /usr/local/dockerContainerConf:/dockerContainerConf:ro \
    -e RESTIC_REPOSITORY='/srv/restic-repo' \
    -e RESTIC_PASSWORD="pass" \
    restic backup /dockerContainerConf

查看已备份数据

docker run -it --rm \
    -v /mnt/disk/backupData/restic-repo:/srv/restic-repo \
    -e RESTIC_REPOSITORY='/srv/restic-repo' \
    -e RESTIC_PASSWORD="pass" \
    restic snapshots

恢复数据

https://restic.readthedocs.io/en/latest/050_restore.html

docker run -it --rm \
    -v /mnt/disk/backupData/restic-repo:/srv/restic-repo \
    -v /mnt/disk/backupData/test:/data \
    -e RESTIC_REPOSITORY='/srv/restic-repo' \
    -e RESTIC_PASSWORD="pass" \
    restic restore 8fcef08d --target /data