Docker Practice 9: Backup Scenarios

Source: Internet
Author: User
Tags mediawiki

12 File Systems

Let's mention two important file system concepts, one is aufs and the other is VFS.

The AUFS is a stackable federated file system similar to UnionFS. It consolidates multiple directories into a single directory. Ubuntu has good support for it, so the image of Docker is stored under the Aufs file system.

VFS is an important concept in the kernel of Linux, which allows systems such as open (), read (), write () to invoke an adhesive layer that does not care about the underlying storage media and file system type.

2 storage of Docker images and containers


The hierarchy of Docker is like.
Docker is installed in the/var/lib/docker directory, where access requires root privileges.

/var/lib/docker# du -sh *1.8G    aufs80K containers36K execdriver452K    graph15M init8.0K    linkgraph.db4.0K    repositories-aufs240M    tmp8.0K    trust203M    vfs28K volumes

From the folder size can be seen Aufs and VFS is actually stored things, at the beginning of the time, my focus on the aufs.

There are currently two Docker images, using the MediaWiki deployed by Docker-compose.

# docker imagesREPOSITORY               TAG                 IMAGE ID            CREATED             VIRTUAL SIZEmysql                    5.7.5               c171a2256c3b        3 weeks ago         322.8 MBnickstenning/mediawiki   latest              d32d732341b0        16 months ago       619.5 MB

The corresponding repositories-aufs are as follows:

/var/lib/docker# cat repositories-aufs | python -mjson.tool{    "Repositories": {        "mysql": {            "5.7.5""c171a2256c3b9d13c77b2b3773eaaad95a9b4a8735613ce46722f79fa29fa366"        },        "nickstenning/mediawiki": {            "latest""d32d732341b07cfc87006d09ea75514d8c10774dfbc83c74034ac28b1491557b"        }    }}

While the tree parameter is available, let's look at the hierarchy of images:

# Docker Images-treewarning:'-tree '  is deprecated, it'll be removed soon. See usage.├─511136ea3c5aVirtualSize:0b│└─36669626e49cVirtualSize:84.98mb│└─d5570ef1464aVirtualSize:84.98mb│└─ theff2cfa64aVirtualSize:85.3mb│└─ef7c16d26957VirtualSize:116.7mb│└─3749Ee37c2a6VirtualSize:116.8mb│└─5431D6b9bc80VirtualSize:116.8mb│└─0dc7d8240120VirtualSize:116.8Mb│└─a37379b8d1ceVirtualSize:116.8mb│└─cad6baf3ee5bVirtualSize:322.8mb│└─facdf8305638VirtualSize:322.8Mb│└─a10cdfaf13cfVirtualSize:322.8mb│└─444b88bd8367VirtualSize:322.8mb│└─ theDfd5776ff8VirtualSize:322.8mb│└─7D0b9c0b29d2VirtualSize:322.8Mb│└─c171a2256c3bVirtualSize:322.8MB Tags:mysql:5.7.5└─8Dbd9e392a96VirtualSize: -mb└─be647841828fVirtualSize: -mb└─7F06ad8f23b1VirtualSize:272.5mb└─9Fc1b767f7ffVirtualSize:383.1mb└─ $af893ffb5fVirtualSize:439.2mb└─xxa79ad7ea4aVirtualSize:439.2mb└─ thef7b013792eVirtualSize:439.2mb└─854A5bd5be72VirtualSize:439.2Mb└─c219ca4d0d53VirtualSize:439.2mb└─ theC69a7e8ad3VirtualSize:439.2mb└─09652Ed5f7efVirtualSize:459.6mb└─814A97e8dc1cVirtualSize:539.6Mb└─a7bc400b42c2VirtualSize:539.6mb└─68013db1eb6dVirtualSize:619.5mb└─ca839611a34fVirtualSize:619.5mb└─ theE9d31943eaVirtualSize:619.5mb└─1B95e1c4efd9VirtualSize:619.5mb└─9df1e07fdf78VirtualSize:619.5mb└─3E8e8966dcfbVirtualSize:619.5mb└─3e0c3340e16eVirtualSize:619.5Mb└─d32d732341b0VirtualSize:619.5MB Tags:nickstenning/mediawiki:latest

Take a look at the graph directory:

/var/lib/docker/graph# lsxxA79ad7ea4a77bac24386226563b86ee92db49073e6417ce10dbe175777b7ff814A97e8dc1c5b86b3a4a21e2c64abac2e69ad1214f084c60e78b7b9b4d91e7509652ed5f7efeb035c7f29e7fe16b600ff4066362ea95f678974d7940f89f021 thedfd5776ff844e112fa504701370e7a0e20ecdf43afc75cf9018f05c6e466990Dc7d82401208db703d519db581d7dddb39a090e2bf0dd6b5a64dcf9a743e6aa854A5bd5be7280e1a53d451e3806aaf202a4cfffdf1701cf10cd1036bccb6bdc170ff2cfa64adbd757c0dad0c1cb4bbb61e11301a16cd8f29b40cb3217ec72548Dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c1b95e1c4efd993116df499fa9951b865ec99e8a455427cffc9c61364bc3c52959Df1e07fdf780918f8fafaba0f5470d1c6357232617e42b6d190383fd0710e3736669626e49C623f3b2aea41052bbc9de0506807d92137bf76c0fd3264eaff349fC1b767f7ff6d935efd6e897882d202fcbd041a154c400b595b9e0f1b2092dc3749ee37c2a6df4df9f720c7c07ecc5af695a2a5853bac1f8ba6450ddc310343 a10cdfaf13cf8dbaa07798f29265ec37a5bec4dc5f2b6f8c449edb2658b0a5713e0c3340e16e991af227912b27441b392762476f15d6749c3c1333fab63c5927 a37379b8d1ce392404d50d97a02afb92bd774a45191b3dc98c512fa6af3943353e8e8966dcfba21708e772ec165edcb617061028572e279decf7b374f4f3a866 A7bc400b42c28673642376884b7a8a93c76548198ebb4c4993a65cdfaf81ccd2 thec69a7e8ad3ba37bfddeaf52ea54381d487311ba5c75d6a91811abeaad8438b be647841828f846812df2968e24aa9db46c1a2033c0c60577e2b91fdcf7d4c09444B88bd8367b8fc2d023b5ceb77cec3784963bbfc03d1d30f96b97a22cfbc44 c171a2256c3b9d13c77b2b3773eaaad95a9b4a8735613ce46722f79fa29fa366 $af893ffb5fe47b7de23a3f2f8972dbf51e78a0327ca46b7848c1cdfd48f97d c219ca4d0d536c79955628e17aa8d6e6b6a61bc50c486bcd304a70a790985627511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 ca839611a34f4eb30e582694d9a1cdabf11d96b4c36bf69c1a82fb069ba0509a5431d6b9bc80429667488287e8189cc4d4b14791e43e45b374e132e340fb15db Cad6baf3ee5b2798947cdcfbdd3bf4c38c3f094bfbec876fb27da426528107fa63e9D31943ea386e435763524d9ea3a8cb253747113abbb53191121b815572da d32d732341b07cfc87006d09ea75514d8c10774dfbc83c74034ac28b1491557b68013db1eb6d12803db7cbb52e95e6f29c8141c095b8cb50d245925d7f70d774 D5570ef1464a43fe282dd2705b38a2d739812b0b8036a49cfa09811737cfbed469f7b013792e1f9c63176a7e348cb38277182f8bcf3d1d6d2c26ff9c4885b4ec Ef7c16d26957dc5dea9ad23433c7dd6400ab0a1a5cf461a080312dfaea50eeee7D0b9c0b29d271a8be6ca9252da15ae4f01dd386ac2b452563232aaaddd5eaf9 facdf830563864336b80233167577315520bca3fbbd86d8f995e40f0e81e238c7f06ad8f23b10227423823e3acc7e368c012f41a30660c3fbad661a9a4f8fe67 _tmp

The long ID corresponds to the tree's short ID, so it's clear. In the above to container file to use the Magic Channel, in fact, is aufs in the MNT.

Backup Scenarios

In the first case, mount the host directory, such as the previous hg-server. Backup is very simple, directly those Hg source directory in the host to do backup.

In the second case, new software needs to be installed in the container. Use the export or Save command.

sudo Docker commit9Ab6e234c9ba Linc-wikisudo docker images REPOSITORYTAGIMAGE ID CREATED VIRTUAL SIZE Linc-wikiLatest B5A1E34B01C2 -Seconds ago689.7Mbsudo Docker Export9Ab6e234c9ba>/home/linc/docker/images-BK/linc-wiki-export.Tarsudo Docker Save Linc-wiki > ../images-BK/linc-wiki-save.Tar$ du-sh *495M Linc-wiki-export.Tar672M Linc-wiki-save.Tarsudo cat/home/linc/docker/images-BK/linc-wiki-export.Tar|sudo dockerImport -Docker_hgwebsudo Docker Load--Input../images-BK/linc-wiki-save.Tar

In the third case, where does the data in MySQL go?
This question has been bothering me for a few days. Take the deployed MediaWiki and say, instead of linking the data file to the host, put it in/var/lib/mysql, as follows:

/var/lib/mysql# lsauto.cnf  ib_logfile0  ib_logfile1  ibdata1  ibtmp1  my_wiki  mysql  performance_schema

I tried the new setup volume but did not succeed, but also did other efforts, have failed. In the last large search, the data files were found to be placed in the VFS.

/var/lib/docker/vfs# tree -L 3.└── dir    └── cb4012594631102fc8a69aa6cb4a9aa2dd2be3d39d2564c94ae91ac5e3eb4aec        ├── auto.cnf        ├── ibdata1        ├── ib_logfile0        ├── ib_logfile1        ├── ibtmp1        ├── mysql        ├── my_wiki        └── performance_schema5directories5files

After trying to put it in the same directory as the Docker in my Ubuntu server virtual machine, MediaWiki with the image of save in host, my MediaWiki is perfectly resurrected in Ubuntu server virtual machine!
In other words, I just need to back up the data on the VFS under Docker in the host system. Problem solving, you can arbitrarily add important content in the wiki without worrying about being destroyed.

Reference:
Http://www.programfish.com/blog/?p=9
http://blog.csdn.net/junjun16818/article/details/38423391
Maintenance of Gitlab: Http://www.tuicool.com/articles/bYbi2mJ

Docker Practice 9: Backup Scenarios

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.