Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
docs(docker): 添加卷数据还原操作
Browse files Browse the repository at this point in the history
  • Loading branch information
zjZSTU committed Dec 4, 2019
1 parent cfefa38 commit 0925835
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/source/docker/storage/[docker volume]创建和管理卷.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,20 @@ $ docker run --rm -it -v VOLUME_NAME:/dbdata --name dbstore ubuntu /bin/bash

```
$ docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
```

## 还原

基本原理:将卷挂载到容器中,通过`tar`命令解压

创建新容器`dbstore2`,将卷挂载到路径`/dbdata`

```
$ docker run --rm -it -v jenkins_home:/dbdata --name dbstore2 ubuntu /bin/bash
```

新建一个窗口,解压压缩包`backup.tar`内容到`dbstore2``dbdata`目录

```
$ docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /dbdata && tar xvf /backup/backup.tar --strip 1"
```

0 comments on commit 0925835

Please sign in to comment.