aboutsummaryrefslogtreecommitdiff
path: root/content/blog/docker/migrate-data-volume.md
blob: 5e05e7246c3075bf7e64af37297a856e29ea8723 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
---
title: "Migrate a docker data volume"
date: 2018-01-30
description: How to migrate a data volume between two hosts
tags:
  - docker
---

## The command

Here is how to migrate a data volume between two of your hosts. A rsync of the proper `/var/lib/docker/volumes` subfolder would work just as well, but here is a fun way to do it with docker and pipes :
```sh
export VOLUME=tiddlywiki
export DEST=10.1.0.242
docker run --rm -v $VOLUME:/from alpine ash -c "cd /from ; tar -cpf - . " \
| ssh $DEST "docker run --rm -i -v $VOLUME:/to alpine ash -c 'cd /to ; tar -xfp - ' "
```