'Restore a mongodb volume from backup file with docker, is it possible?
from docker documentation
there is a way to save a backup of a volume and this is working fine with mongo, so when i run the command to backup the mongodb volume "/data/db" i got a backup.tar (35 file+dir) file on my host machine.
but when i want to restore that volume from the backup.tar file i got some error so this is the command:
sudo docker run --rm --volumes-from server_mongo_1 -v $(pwd):/backup ubuntu bash -c "cd /data && tar xvf /backup/backup.tar --strip 1"
the error is that this command is working and unziping the files from the backup.tar file to the /data/db (25file+dir) of the mongo container, but this not deleting the old data in /data/db so this lead to fail the mongo container and stop running and never run again ( we finish with 45 files+dir) ...
i've tried to remove the /data/db directory before unziping with cd /data && rm -r db but got an error rm: cannot remove 'db': Device or resource busy
can you help me please ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
