Maintenance¶
Application backup¶
Database
sudo -u postgres pg_dump --no-acl --no-owner -Fc geotrekdb > `date +%Y%m%d%H%M`-database.backup
Media files
tar -zcvf `date +%Y%m%d%H%M`-media.tar.gz /opt/geotrek-admin/var/media/
Configuration
tar -zcvf `date +%Y%m%d%H%M`-conf.tar.gz /opt/geotrek-admin/var/conf/
Application restore¶
If you restore Geotrek-admin on a new server, you will have to install PostgreSQL and PostGIS and create a database user first. Otherwise go directly to the database creation step.
sudo apt install postgresql-14-pgrouting
sudo -u postgres psql -c "CREATE USER geotrek PASSWORD 'geotrek';"
Note
The installation command will never be the same depending on the servers hosting the database (Ubuntu 22, 24 / official repository / PostgreSQL repository / RedHat, etc.).
Here is an example with the command to run to install PostgreSQL on Ubuntu 24.0 (Noble) :
sudo apt install postgresql-17-pgrouting
sudo -u postgres psql -c "CREATE USER geotrek PASSWORD 'geotrek';"
Create an empty database (geotrekdb
in this example):
sudo -u postgres psql -c "CREATE DATABASE geotrekdb OWNER geotrek;"
sudo -u postgres psql -d geotrekdb -c "CREATE EXTENSION postgis;"
sudo -u postgres psql -d geotrekdb -c "CREATE EXTENSION postgis_raster;"
sudo -u postgres psql -d geotrekdb -c "CREATE EXTENSION pgcrypto;"
sudo -u postgres psql -d geotrekdb -c "CREATE EXTENSION pgrouting;"
Restore backup:
pg_restore -U geotrek -h localhost --clean --no-acl --no-owner -d geotrekdb 20200510-geotrekdb.backup
If errors persist, rename your database and recreate a fresh one, then restore.
Extract media and configuration files:
tar -zxvf 20200510-media.tar.gz
tar -zxvf 20200510-conf.tar.gz
Follow Fresh installation method. Choose to manage database by yourself.
PostgreSQL optimization¶
Increase
shared_buffers
andwork_mem
according to your RAMUse pg activity for monitoring
Access your database securely on your local machine (QGIS)¶
Instead of opening your database to the world (by opening the 5432 port for example), you can use SSH tunnels. Follow this tutorial for more information (in french).
Manage Cache¶
You can purge application cache :
with command line :
sudo geotrek clearcache
docker compose run --rm web ./manage.py clearcache
in Geotrek-admin interface :
https://<server_url>/admin/clearcache/