www/content/blog/docker/migrate-data-volume.md

18 lines
602 B
Markdown
Raw Normal View History

2020-04-28 17:29:52 +02:00
---
title: "Migrate a data volume"
date: 2018-01-30
description: How to migrate a data volume between two hosts
tags:
- docker
2020-04-28 17:29:52 +02:00
---
## 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 :
2020-04-28 17:29:52 +02:00
{{< highlight 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 - ' "
{{< /highlight >}}