Docker Container Data management: Mount, backup, restore

Source: Internet
Author: User
Tags directory create

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.