Hi, here I want to share you the detailed steps and instructions for migrating a Wiki.js installation from one server to another.
After lots of tries, I want to share you the definitive guide to do it in less than 10 simple steps:
_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.
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!
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 :)
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.
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.