Wiki: Migrate Wiki.js from one server to another [INSTRUCTIONS] ✅

Created on 9 Sep 2020  Â·  2Comments  Â·  Source: Requarks/wiki

Hi, here I want to share you the detailed steps and instructions for migrating a Wiki.js installation from one server to another.

We have been using Wiki for a while and we had to move our installation to a new server. Our Docker knowledge is very basic -and that's why we chose Wiki.js, because of the simplified and easy setup-, but the migration process was really complex for us and we had to put some effort to make it work because all our documentation and data was already in it.
We have been struggling on this for some weeks because there are not any clear instructions on the official docs and no one replied our tickets/issues with useful information, but just vague instructions that made us even more confused.

After lots of tries, I want to share you the definitive guide to do it in less than 10 simple steps:

Before you begin

_First, you obviously want to install Wiki.js on your new server. If you have already done it ignore this step. If not, you can use this guide for your full setup (Docker + DB + UFW + Wiki): https://docs.requarks.io/install/ubuntu --> This guide will use this setup instructions as reference._
_This should also work if you are moving Wiki.js from / to a marketplace one-click deployment like Digitalocean's._
This simple procedure will include the migration of: all your data, docs, content, configs and customizations.

On the OLD server:

Go to the OLD server and execute the following commands. Before you run these make sure your old Wiki.js (the one you want to move) is currently working and the docker containers are running (you can check doing: _docker ps_ and/or visiting your wiki site)

1. Make a database backup. Note: in this case: "db" is our postgres container name, "wiki" is the username of our DB and "wikibackup" is the backup filename. If you have followed the official setup manual this should work. Otherwise, please replace the name with your container / db / username.

cd ~/
docker exec db pg_dumpall -U wiki > wikibackup

2. Move your database backup you just created, "_wikibackup_", from your old server over to your new server. You can use rsync like this (make sure you replace this example your new server ip):

rsync -rP ~/wikibackup [email protected]:~/

3. Copy your db pass. (Again, please note this should only work if you used the official documentation setup instructions. If you changed your wiki postgres db password manually or used other custom file location, please make sure you copy it from correctly):

cat /etc/wiki/.db-secret
123456789=#! ---> copy your old db password!

On the new server:

4. On the new server replace the .db-secret file with your old db password. (Replace 123456789=#! with your old server password..)

mv  /etc/wiki/.db-secret  /etc/wiki/.db-secret.BAK
echo "1233456789=#!" >> /etc/wiki/.db-secret

5. Stop the wiki and wiki-update-companion containers:

docker stop wiki
docker stop wiki-update-companion

6. Remove the default database:

docker exec -it db dropdb -U wiki wiki

7. Create a new empty db:

docker exec -i db createdb -U wiki wiki

8. Restore your db backup:

cat ~/wikibackup | docker exec -i db psql -U wiki

9. Start your containers:

docker start wiki
docker start wiki-update-companion

Enjoy :)

This solves: #2336 #2328 and probably many others :)
help

Most helpful comment

The stop/start wiki-update-companion step is not necessary. This container doesn't need to be stopped or restarted for this procedure.

Thank you for taking the time to document step by step. I'll make sure to add it to the official docs.

All 2 comments

The stop/start wiki-update-companion step is not necessary. This container doesn't need to be stopped or restarted for this procedure.

Thank you for taking the time to document step by step. I'll make sure to add it to the official docs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

den1622 picture den1622  Â·  3Comments

LionNatsu picture LionNatsu  Â·  3Comments

sleepadru picture sleepadru  Â·  4Comments

leandro-hermes picture leandro-hermes  Â·  4Comments

failover88 picture failover88  Â·  4Comments