作者:E4b9a6, 创建:2021-06-16, 字数:1345, 已阅:77, 最后更新:2024-03-10
在NAS上运行的Docker容器PhotoPrism需要备份以防万一(当然备份原始照片数据更重要)
备份步骤
恢复步骤
全部步骤指令
# 打印当前所有容器
❯ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a48bc98b4a21 photoprism/photoprism:latest "/entrypoint.sh phot…" 2 weeks ago Up 5 hours 0.0.0.0:32342->2342/tcp chancel_photoprism_1
f1d7d5ac091f mariadb:10.5 "docker-entrypoint.s…" 2 weeks ago Up 5 hours 3306/tcp chancel_mariadb_1
# 提交需要备份的容器
❯ docker commit -p a48bc98b4a21 photoprism-container-backup
# 查看镜像列表
❯ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
photoprism-container-backup latest cc71161fb644 4 minutes ago 14.3GB
hello-world latest d1165f221234 2 weeks ago 13.3kB
mariadb 10.5 e27cf5bc24fe 2 weeks ago 401MB
photoprism/photoprism latest f81f7b1e47a4 3 weeks ago 1.3GB
# 导出已保存的镜像备份为tar压缩文件
❯ docker save -o ~/photoprism-container-backup.tar photoprism-container-backup
# 导入已保存的镜像备份tar文件
❯ docker load -i ~/photoprism-container-backup.tar
# 重新使用镜像运行容器
docker run -d -p 32342:2342 container-backup photoprism-container-backup