title | description | published | date | tags | editor | dateCreated |
---|---|---|---|---|---|---|
Transfer Wiki.js between servers |
How to migrate your installation to a new server |
true |
2023-01-29 21:57:54 UTC |
markdown |
2020-09-13 03:44:51 UTC |
This guide assumes you're currently using a PostgreSQL database installation of Wiki.js 2.x running on Docker on Linux, as detailed in the Ubuntu installation guide. This is the default installation method for 1-click images for DigitalOcean and AWS Marketplace.
Note that it is NOT possible to "convert" an installation from a different database engine (e.g. MySQL, MSSQL or SQLite). You should instead export content manually to disk and re-import it into a new installation. {.is-danger}
Context: New server{.caption}
Let's start by setting up the destination server. Follow the Ubuntu installation guide up until the "Access the setup wizard" step (don't do this step, stop right after starting the Docker containers).
You should now have a fully setup server with a PostgreSQL database, a Wiki.js installation and the Wiki.js auto-updater all running in Docker containers.
Context: Old server{.caption}
On your old server where your previous installation is located, make a full database dump:
docker exec db pg_dump wiki -U wiki -F c > wikibackup.dump
In the above command, the PostgreSQL docker container is named
db
and we're using the database namewiki
and userwiki
. This is the default if you followed the tutorial mentionned in the Getting Started section above. {.is-info}
This will create a new file wikibackup.dump
in the current directory.
Context: Old server{.caption}
We'll now transfer the backup file onto the new server. There're several methods to copy files between servers but we'll use rsync for this example. Replace YOUR-NEW-SERVER-IP
in the command below with the IP address of your new server.
rsync -P wikibackup.dump root@YOUR-NEW-SERVER-IP:~/wikibackup.dump
This assumes that you have previously configured your new server to accept SSH connections from your old server. To do so, you need to add the public key of the old server into the authorized_keys of the new server. You can learn how in this tutorial. {.is-info}
Context: New server{.caption}
We're now ready to restore the database dump into the new database.
On the new server, stop the wiki
docker container:
docker stop wiki
Restore the wikibackup.dump
file into a new database, first dropping the existing empty DB:
docker exec -it db dropdb -U wiki wiki
docker exec -it db createdb -U wiki wiki
cat ~/wikibackup.dump | docker exec -i db pg_restore -U wiki -d wiki
We can now restart the wiki
container:
docker start wiki
That's it!