Pages
  • Homepage
  • Queztaz/Tech Inventory
  • Emacs/Emacs With BiDirectional Google Calendar Sync
  • Emacs/Setting up Mu4e and Multiple Gmail Accounts
  • Emacs/EWW Hacks
  • Linux/Creating an Offline Debian Mirror Repository
  • Linux/Migrate Wiki.js to Another Server
  • Linux/Adding Bitwarden to the Pinephone Pro
  • Pinebook Pro/Custom Kernel
  • Pinebook Pro/Keyboard Firmware Update
  • Pinebook Pro/Netbsd Installation
  • Pinebook Pro/Setting Up Zram
  • Pinebook Troubleshooting/Pro Common Issues
  • Pinebook Pro/Use NVME as Root
  • Pinebook Pro/Write to SPI Flash
  • Qemu/Chroot Into a Different Architecture
  • Qemu/Choot Into an Img File
  • Qemu/Mount Virtual Images
  • Qemu/Windows Xp Fix Smb Not Working
  • Qemu/Windows Xp Installation
  • Misc/Finding the Default Wireless Password to TG1672G Routers
  • Misc/Running Ollama Portably
  • Windows/Cloning a Bios Boot Drive to Disimilar Hardware with UEFI
  • Windows/Automatic CHKDSK Scans Using Powershell & Email Alerts
  • Windows/Creating a Decent Portable Terminal
  • Windows/Merging HyperV Snapshots With Powershell
  • Windows/Simulating Bad Blocks on NTFS Filesystems
  • Windows/Creating and Viewing a Storport on Windows Server
  • Mikrotik/Creating a Client to Site VPN With
  • Mikrotik/Securing Router With Firewall
  • Mikrotik Setup Dynamically Changing IP With No-IP Api
Homepage
  • Homepage
  • Queztaz/Tech Inventory
  • Emacs/Emacs With BiDirectional Google Calendar Sync
  • Emacs/Setting up Mu4e and Multiple Gmail Accounts
  • Emacs/EWW Hacks
  • Linux/Creating an Offline Debian Mirror Repository
  • Linux/Migrate Wiki.js to Another Server
  • Linux/Adding Bitwarden to the Pinephone Pro
  • Pinebook Pro/Custom Kernel
  • Pinebook Pro/Keyboard Firmware Update
  • Pinebook Pro/Netbsd Installation
  • Pinebook Pro/Setting Up Zram
  • Pinebook Troubleshooting/Pro Common Issues
  • Pinebook Pro/Use NVME as Root
  • Pinebook Pro/Write to SPI Flash
  • Qemu/Chroot Into a Different Architecture
  • Qemu/Choot Into an Img File
  • Qemu/Mount Virtual Images
  • Qemu/Windows Xp Fix Smb Not Working
  • Qemu/Windows Xp Installation
  • Misc/Finding the Default Wireless Password to TG1672G Routers
  • Misc/Running Ollama Portably
  • Windows/Cloning a Bios Boot Drive to Disimilar Hardware with UEFI
  • Windows/Automatic CHKDSK Scans Using Powershell & Email Alerts
  • Windows/Creating a Decent Portable Terminal
  • Windows/Merging HyperV Snapshots With Powershell
  • Windows/Simulating Bad Blocks on NTFS Filesystems
  • Windows/Creating and Viewing a Storport on Windows Server
  • Mikrotik/Creating a Client to Site VPN With
  • Mikrotik/Securing Router With Firewall
  • Mikrotik Setup Dynamically Changing IP With No-IP Api

Linux/Migrate Wiki.js to Another Server

Table of content
  • Migrating Steps
  • Overview
  • Exporting the database on old server
  • Importing the database

Documented steps I took to migrate Wiki.JS from one server to another. The original instance was running on docker. The new instance is on an LXC container.

Migrating Steps

Overview

The original server runs WikiJS through docker. One container contains the PostgresDB and the other contains the node server

New server will be running WikiJS natively

Exporting the database on old server

From the old server, run the following command to dump the database to a file.

pg_dump wiki -U wiki -F c > wikibackup.dump

I'm using podman to host my containers. My command is a little different. I'll run pgdump on the container running the node server

podman exec 5eab35c74818 pg_dump wiki -U wikijs -F c > wikibackup.dump

Now move the dump file to your new server. I like using python's http server.

# Run on the old server
python -m http.server

# Download the file on the new server
wget https://OLD-SERVER-IP/wikibackup.dump

Importing the database

Start with installing postgres

sudo apt install postgresql

Now edit the following lines in /etc/postgresql/NUMBER/main/pg_hba.conf

# CHANGE THIS LINE TO TRUST
#local   all             postgres                                peer
local   all             postgres                                trust

# CHANGE THIS LINE TO MD5
#local   all             all                                    peer 
local   all             all                                     md5

Restart the postgres service

systemctl restart postgresql
systemctl enable postgresql

Now log into the postgres user account and create the database. This will be what we later merge our dump into. Fyi, if your docker container had a DB different than "wikijs", make sure to create that user instead.

sudo -i -u postgres
psql
CREATE USER wikijs WITH PASSWORD 'your_password';
CREATE DATABASE wiki;
GRANT ALL PRIVILEGES ON DATABASE wiki TO wikijs;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO wikijs;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO wikijs;
ALTER USER wikijs WITH SUPERUSER;
ALTER USER wikijs WITH CREATEDB;
ALTER USER wikijs WITH CREATEROLE;
ALTER USER wikijs WITH REPLICATION;
ALTER USER wikijs WITH BYPASSRLS;
\q
exit

With the database created, restore the database dump you transferred to the new server earlier.

pg_restore wikibackup.dump.1 -d wiki -U wikijs

Install the Wiki server, then edit the config.yml file to include the username and password created in the previous section.

# Installing Node
apt install curl
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt install -y nodejs

# Installing the application
wget https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz
mkdir /var/wiki
tar xzf wiki-js.tar.gz -C /var/wiki
cd /var/wiki
cp config.sample.yml config.yml
vim config.yml

At this point you can test the server by running node server in the wiki folder. Create a systemd unit afterward to start the service on boot

cat <<OEM >/etc/systemd/system/wiki.service
[Unit]
Description=Wiki.js
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/node server
Restart=always
# Consider creating a dedicated user for Wiki.js here:
User=nobody
Environment=NODE_ENV=production
WorkingDirectory=/var/wiki

[Install]
WantedBy=multi-user.target
OEM

systemctl daemon-reload
systemctl enable --now wiki
PREVRANDOMNEXT