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

Commit

Permalink
docs(storage): 备份卷数据
Browse files Browse the repository at this point in the history
  • Loading branch information
zjZSTU committed Nov 22, 2019
1 parent 46b94b3 commit b53b81a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/source/docker/storage/[docker volume]创建和管理卷.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,24 @@ Deleted Volumes:
test
Total reclaimed space: 0B
```

## 备份

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

创建新的容器`dbstore`,挂载卷到路径`/dbdata`

```
$ docker run --rm -it -v VOLUME_NAME:/dbdata --name dbstore ubuntu /bin/bash
```

新建一个窗口

* 启动新容器并挂载容器`dbstore`
* 挂载本地文件夹到容器目录`/backup`
* 执行`tar`命令,打包`/dbdata`目录到`/backup/backup.tar`

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

0 comments on commit b53b81a

Please sign in to comment.