This is a little resume of how I’m doing a backup procedure of my wikijs database based in Docker-compose.

Below are the systems used in my enviroment:

  • Project: Wikijs 2.0 Beta
  • Platform: Docker-Compose
  • DB: Postgres (9.6.14)
  • Server: Fedora Server 30.x86_64
  • Workstation: Windows 10 (provided by work) 😬
PSQL basic commands:

Here are 4 basic commands I use to connect into my Postgre DB and check out DB list and quite.

  • $psql -h localhost -p 5416 -U <my-user> -d <my-database>

  • $psql -p 5432 -U wikijs -d wiki

  • to show databases: wiki=# \l

  • to exit: wiki=# \q

ℹ️ Asummied you have the Docker-compose up and running that will be our starting point.

Backup Procedure

  1. Stop you DB client (in our case stop the service “wiki”)
$ docker stop <name-container>
  1. From your localhost ( my case Fedora) create a folder for the backup.

  2. Create the DB backup:

docker exec docker_yml_db_1 pg_dumpall -U wikijs > backup.sql

or

docker exec docker_yml_db_1 pg_dumpall -U wikijs > backup_`date +%d-%m-%Y"_"%H_%M_%S`.sql

😀 It’s done, with the steps describe above you can use the .sql file to restore your entire wikijs data to other system.

Restore procedure

ℹ️ Asummied you have the Docker-compose up and running that will be our starting point.

  1. Stop you DB client (in our case stop the service “wiki”)
$ docker stop <name-container>
  1. ⚠️ Delete database:
docker exec -it wikijs_db_1 dropdb -U wikijs wiki
  1. Create database:
docker exec -it wikijs_db_1 createdb -U wikijs wiki
  1. Restore database:
cat backup.sql | docker exec -i wikijs_db_1 psql -U wikijs wiki
  1. Start up the wiki service
$ docker start <name-container>

Finally we have restore/exported our data. This is an useful method I use to do my Wikijs data portables.

Extra command:
  • Container to local system:
docker cp -a [container_name]:/wiki C:\Users\jcr\Desktop\docker_yml\backup_db
  • Connect into the postgre_container:
docker exec -it wikijs_db_1 psql -p 5432 -U wikijs -d wiki

The information below is being worked on! It’s Beta release. (aim: describes how to export by FTP the backup file)

FTP

To transfer the file between the container and Host I use vsftpd with the basic config.

Using systemd to start the service:

$ systemctl start vsftpd

Start as client by Filezilla:

  • user: xxxxx
  • passwd: yyyyy
  • port: 21
  • IP: locahost

for more detail.