These are steps I came up with when exploring this issue as part of the conversation at Data persistence when upgrading/downgrading Central. If others have better strategies, please chime in.
The first step is to identify the data directory that currently is being used by your system. You can do this with docker inspect --type container central_postgres_1 -f '{{(index .Mounts 0).Source}}'
. You should get a folder in /var/lib/docker/volumes/
with a long, random name. Make a note of the long name. I'll use target
as a stand-in for that name below.
Then you need to find the volume that was previously mounted (before the down
) and holds your data. I did this by first doing docker volume ls
to get all of the volumes the system knows about. You'll see several volumes with long random names. One of them is the one you identified above and another is the one you're looking for. These names correspond to folders in /var/lib/docker/volumes
. I manually copied and pasted each name to the end of that folder and added _data
to create the full paths and listed the contents of each: ls /var/lib/docker/volumes/195[...]15412/_data/
. I repeated until I found a directory (other than target
from above) with folders with the pg_
prefix (e.g. pg_clog
). Make a note of the long name. I'll use source
for it.
Now you know the volume that holds your data (source
) and the volume that's currently being mounted (target
). Your goal is to put the contents of source
at target
. I did:
cd
cd central
docker-compose stop
pushd /var/lib/docker/volumes
mv target target.bak
mv source target
popd
docker-compose up -d
Go to your site in a browser and try to log in with an account that previously existed. If that doesn't immediately work, try doing another stop
followed by up
.
Once things are working as expected, you can remove the backup folder you made: rm target.bak
Do you have prior Docker experience and so are already used to removing containers? Or maybe you instinctively used down
as an opposite of up
? Any context you can give us into what happened would be helpful!