Backup and restore of the Chirpstack PostgreSQL and Redis databases.
Step-by-step procedure document. Authors: Joe Smissen and Carlos Acouda.
Restore was tested on a new CS install on a different Linux server.
Thanks for this document. What is the postgres_user_password referenced here? I have set up postgres on Ubuntu using the Chirpstack QS guide which sets up chirpstack_as/_ns users but I can’t see what to use for postgres, template1, and template0. Sorry if I missed this somewhere but I have reviewed the docs several times and it still eludes me.
Does anyone have a copy of this file? PDF on github is corrupted (with & without signing in). Error is:
Error rendering embedded code
Invalid PDF
Did anyone retain a copy?
I’ve been using V3 for last 2 years, but time has come to relearn (everything) so I can migrate to V4.
I have 30+ activated sensors so I’d rather not start from scratch.
I wrote this procedure a while ago:
Backup Process
0) ssh to machine and enter the chirpstack-docker folder
$ ssh <user>@<chirpstack-server>
$ cd chirpstack-docker
1) Ensure Docker is down so no containers try to write while backup occurs.
$ sudo docker compose down
2) Copy redis data dump
$ sudo cp /var/lib/docker/volumes/chirpstack-docker_redisdata/_data/dump.rdb redisbackup.rdb
3) Create a file for psql backup dump
$ touch postgresbackup
4) Start only the postgres container
$ sudo docker compose up postgres -d
5) dump all sql backup commands from container and pipe into backup file
$ sudo docker exec -it chirpstack-docker-postgres-1 pg_dumpall -c --no-password -h localhost -U postgres > postgresbackup
Restoral process
0) ssh to machine and enter chirpstack-docker folder
$ ssh <user>@<chirpstack-server>
$ cd chirpstack-docker
1) Ensure Docker is down so no containers try to write while backup occurs.
$ sudo docker compose down
2) Make a copy of current redis database (As a safe measure)
$ sudo cp /var/lib/docker/volumes/chirpstack-docker_redisdata/_data/dump.rdb redisdatareplaced.rdb
3) Delete old data dump and copy backup into volume
$ sudo rm /var/lib/docker/volumes/chirpstack-docker_redisdata/_data/dump.rdb
$ sudo cp redisbackup.rdb /var/lib/docker/volumes/chirpstack-docker_redisdata/_data/dump.rdb
4) Change permissions of new dump file
$ sudo chown lxd:<user>l /var/lib/docker/volumes/chirpstack-docker_redisdata/_data/dump.rdb
$ sudo chmod 600 /var/lib/docker/volumes/chirpstack-docker_redisdata/_data/dump.rdb
5) Start only postgres containers
$ sudo docker compose up postgres -d
6) Rebuild SQL database from backup
$ sudo docker compose exec -T postgres psql -h localhost -U postgres < postgresbackup
Although I’m fairly certain I’ve seen slightly cleaner ways since (the idea is still the same though, copy the redis data dump, and pg_dump the psql database) but I almost feel like I saw a built in command to automate the process or something similar.
If you’re coming from V3 you will also have to do the v3 to v4 migration process, or if starting from scratch the [release] ChirpStack v4.7 redis to postgres device session migration after your backup.