Mount, back up, and restore data.
To create a centralized volume group:
Docker run--name dbdata-v/dbdata centos7:file Echo " data-only container for MySQL. "
Mount using:
Docker Run-rt--volumes-from dbdata Centos7:tar/bin/bash
Cd/dbdata
Touch AA bb cc DB3:AA
Backup:
[email protected] backup]# Docker run--name backup-file-d--volumes-from dbdata-v/backup:/backup Centos7:tar tar cvf /backup/$ (date +%m%d-) backup.tar/dbdata
[email protected] backup]# LL
-rw-r--r--1 root root 10240 December 2 14:48 1202-backup.tar
[Email protected] dbdata]# RM-RF * #删除所有数据
[[email protected] dbdata]# ls
Recovery:
[email protected] dbdata]# Docker run-d--name recover-file2--volumes-from dbdata-v/backup:/backup Centos7:tar tar x Vf/backup/1202-backup.tar
To view the recovery results:
[[email protected] dbdata]# ls
AA bb cc DB3:AA # #数据已恢复
1. Create: Mount local/dbdata Directory Create a data volume container named Dbdata, which is assigned to other containers as the same container.
2. Mount: Use--volumues-from dbdata to mount the data volume container into the container using other containers.
3. Backup: Create a backup container named Backup-file mount the data volume container dbdata, then mount the local directory/backup into the container, and execute the TAR command to package the contents of the data volume container dbdata to the/backup directory for synchronization to local.
4, Restore: Create the container name Recover-file2 mount the data volume dbdata and the local directory/backup, and then restore the backup files in the local directory 1202-backup.tar to the data volume, to achieve the effect of recovery.
Docker Container Data management: Mount, backup, restore