Docker Community Forums

Share and learn in the Docker community.

Recommend way to move volumes to new server?

hello community,

what is the recommend way to move my docker-compose setup to a new server?
my applications (owncloud) uses named volumes (as fare as i understand)

$ docker volume ls
DRIVER              VOLUME NAME
local               owncloud-docker-server_backup
local               owncloud-docker-server_files
local               owncloud-docker-server_mysql
local               owncloud-docker-server_redis

$ sudo ls -l /var/lib/docker/volumes
total 60
-rw------- 1 root root 65536 Nov 27 12:22 metadata.db
drwxr-xr-x 3 root root  4096 Mär  3  2020 owncloud-docker-server_backup
drwxr-xr-x 3 root root  4096 Mär  3  2020 owncloud-docker-server_files
drwxr-xr-x 3 root root  4096 Mär  3  2020 owncloud-docker-server_mysql
drwxr-xr-x 3 root root  4096 Mär  3  2020 owncloud-docker-server_redis

is it possible to just copy the volumes (/var/lib/docker/volumes) and the docker-compose.ymland .env files over to the new server (via rsync or similar) and then start up there again?

i am thankfull for any tipps :slight_smile:

sunny greetings
stefan

Sure, of course it’s possible.

dd if=/dev/mygroup-mylv | ssh 192.168.1.103 dd of=/dev/newvgroup-newlv
Boom.

Do yourself a favor, though, and use something larger than the default blocksize. Maybe add bs=4M (read/write in chunks of 4 MB). You can see there’s some nitpicking about blocksizes in the comments; if this is something you find yourself doing fairly often, take a little time to try it a few different times with different blocksizes and see for yourself what gets you the best transfer rates.

Answering one of the questions from the comments:

You can pipe the transfer through pv to get statistics about the transfer. It’s a lot nicer than the output you get from sending signals to dd.

I will also say that while of course using netcat – or anything else that does not impose the overhead of encryption – is going to be more efficient, I usually find that the additional speed comes at some loss of convenience. Unless I’m moving around really large datasets, I usually stick with ssh despite the overhead because in most cases everything is already set up to Just Work.

thanks lewish95 for your reply.
(also it is a full copy of this answer on serverfault from 2012 by larsks: https://serverfault.com/a/358233)

i have read in some answers on my search-journey that it is not possible to just copy the full /var/lib/docker/ folder. can someone explain why or under what cicumstances it could be fine?

i will now just try with the following approach:

- run my docker-compose file
- shut down docker
- with this the volumes are created
- then copy the content of the four volume directories to the new server
- start up docker
- hope it all works out ;-)

i will keep you updated

lewish95 appears to be a Let me Google that for you bot. As you noted, the text in the reply by lewish95 was copied from elsewhere.

thanks @clocks - i did not now that such bots exists…
this one at least violates the community guidelines
so should i flag the post?

1 Like

update:
this approach did work! :slight_smile:

Being an admin on another Discourse site, I know that flags work either by intervention from a moderator or admin, or if the configuration of the site allows it, by enough flags from the community to have it removed. IRCC it takes 3 flags of the same from the community.

As such I will flag this one and then see what happens.


Here is the procedure I used to flag the post

  1. Access the post
  2. At the bottom of the post click image
  3. Click the image
  4. Select image
  5. Paste in You may not post anything digital that belongs to someone else without permission.
2 Likes

meta:
thanks @clocks for the detailed explanation :+1:
in the best case all users have done the discobot tutorial - then they know how to flag :wink:
i have submitted my flag… we will see.

I joined in on the flagging earlier as well. As a matter of fact, I checked clocks profile for threads where he left the “lmgtfy” post and flagged lewish95’s post on them as well. I assume this makes 2 of 3 flaggs for those threads. Maybee you want to join on those threads as well :slight_smile:

@clocks: I very much appreciate what you are doing! In the early days I made a samilar effort and flagged the content… but as nothing happend, I gave up on it. This time I feel we will have more flaggs on the same post, which hopefully result in an outcome different then just beeing ignored (again!)

1 Like

Part of the reason I am here is to obviously learn more about Docker, but the other part of the reason is that being an admin on a Discourse site, one way to learn more about Discourse is to visit other sites. You would be amazed at how different they are in both how the content is managed and how people communicate. I have yet to find two sites alike.

In looking at the groups here there is a moderators group but if you look, they have been absent for years or just show up occasionally. On the sites that I know are very active an popular, you will see several of the admins and moderators being active daily.

IMHO what this site needs is to get some admins and moderators who would make this site better. One thing that just annoys me every time I look at a topic is the banner covering up the title. You would think that would be fixed right away.