Skip to content

Instantly share code, notes, and snippets.

@keepitsimple
Last active January 10, 2022 12:30
Show Gist options
  • Save keepitsimple/d112615ccb620569c151201e85217791 to your computer and use it in GitHub Desktop.
Save keepitsimple/d112615ccb620569c151201e85217791 to your computer and use it in GitHub Desktop.
Docker-compose: create mongo dump as local archive and restore MongoDB from archive
# Make mongodb backup as gzipped archive -T very important if you use docker-compose
docker-compose exec -T [mongo service name] mongodump --db=[dbname] --gzip --archive|cat >dump_$(date '+%d-%m-%Y_%H-%M-%S').gz
#Restore mongodb from gzipped archive
docker-compose exec -T mongo mongorestore --archive --gzip < dump_xxx.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment