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

Given 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 :wink:

i will keep you updated

update:
this approach did work! :slight_smile: