Skip to content

Export Docker Mongo Data

Lauri Ojansivu edited this page Mar 8, 2018 · 37 revisions

Important info

You need to stop Wekan before importing MongoDB database with command

mongorestore --drop

And also check that in your start-wekan.sh or docker-compose.yml or similar that you have corrent MongoDB database name admin, wekan, etc. Otherwise it will be empty.


Check from your Dockerfile or docker-compose.yml what is name of MongoDB container. It can be wekan-db, mongodb or something else.

  1. You can run Wekan on Docker locally like this on http://localhost:8080/ (or other port it you change 8080 in script):
docker run -d --restart=always --name wekan-db mongo:3.2.18

docker run -d --restart=always --name wekan --link "wekan-db:db" -e "MONGO_URL=mongodb://db" -e "ROOT_URL=http://localhost:8080" -p 8080:80 wekanteam/wekan:latest
  1. List docker containers, your ID:s will be different:
docker ps

Result:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
1234wekanid        wekanteam/wekan:latest    "/bin/sh -c 'bash $ME"   About an hour ago   Up 46 minutes       0.0.0.0:8080->80/tcp   wekan
4321mongoid        mongo               "/entrypoint.sh mongo"   About an hour ago   Up 46 minutes       27017/tcp              wekan-db
  1. Enter inside mongo container:
docker exec -it wekan-db bash
  1. OPTIONAL: If you want to browse data inside container, you can use CLI commands like listed at

https://docs.mongodb.com/manual/reference/mongo-shell/

like this:

> mongo             <==== START MONGO CLI
MongoDB shell version: 3.2.18
connecting to: test
Server has startup warnings: 
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] 
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] 
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-06-25T11:39:55.913+0000 I CONTROL  [initandlisten] 
> show dbs           <=== SHOW DATABASES
admin  0.034GB
local  0.000GB
> use admin          <=== CHANGE TO USE ADMIN DATABASE
switched to db admin
> show collections   <=== SHOWS TABLES
activities
boards
card_comments
cards
cfs._tempstore.chunks
cfs.attachments.filerecord
cfs_gridfs._tempstore.chunks
cfs_gridfs._tempstore.files
cfs_gridfs.attachments.chunks
cfs_gridfs.attachments.files
esCounts
lists
meteor-migrations
meteor_accounts_loginServiceConfiguration
presences
users
> db.users.find()     <=== LISTS ALL USERS
(list of all users here)
> exit                <=== EXIT MONGO CLI
  1. Go to /data directory:
cd /data
  1. Backup database to files inside container to directory /data/dump, only Wekan database with name "admin" is included, not local:
mongodump
  1. Exit from inside of container:
exit
  1. Copy backup directory /data/dump from inside of container to current directory:
docker cp wekan-db:/data/dump .

9a) Restore backup later:

docker cp dump wekan-db:/data/
docker exec -it wekan-db bash
cd /data
mongorestore --drop --db wekan dump/wekan/
exit

That dbname can be for example wekan:

mongorestore --drop --db wekan dump/wekan/

9b) Or restore to another mongo database, in different port:

mongorestore --port 11235
  1. If you would like to browse mongo database that is outside of docker in GUI, you could try some admin interface:

https://docs.mongodb.com/ecosystem/tools/administration-interfaces/

  1. If you sometime after backups want to remove wekan containers to reinstall them, do:
docker stop wekan wekan-db
docker rm wekan wekan-db

Then you can reinstall from step 1.

  1. If latest version of Wekan Docker image is broken, here's how to run older version:

https://github.com/wekan/wekan/issues/659

Wekan

General

Support priorities for new features and bugfixes

  1. Commercial Support
  2. Community Support
  3. Debugging

Security

Backup

Repair

Themes

Features

Email

Logs and Stats

Migrating

Required Settings

Download

Webservers

REST API Docs

REST API issue

REST API client code

Webhooks

Case Studies

Development

Issues

Clone this wiki locally