13.3.3. Backup and restore¶
As mentioned above NextGIS Web uses two data storages for different types of data:
PostgreSQL database used as general purpose relational database.
Filesystem storage used for storing BLOBs like raster, attachments, etc.
Also NextGIS Web provides tools for backup and restore this data to / from single-file archive. You can use any destination directory but these tools provide some defaults wich may be usefull.
So before we begin, let’s create default backup directory in
$ mkdir backup
And set up backup directory in
[core] # Other config options go here backup.path = /srv/ngw/backup
To create a backup you need to run command
nextgisweb backup and it will
create backup and print it’s filename:
$ nextgisweb backup /srv/ngw/backup/20200721-234619.ngwbackup
By default NextGIS Web uses strftime formatted for filename which is
%Y%m%d-%H%M%S.ngwbackup. In the example below 2020 is a year, 07 is a
month, 21 is a day and so on. Note that timestamps are always stored in UTC.
Now try to restore NextGIS Web from previously created backup. You don’t need to stop NextGIS Web service during backup but you need to stop it during restore. If you used systemd in the previous section just run as root following command:
# systemctl stop ngw.service
nextgisweb restore command with filename argument:
$ nextgisweb restore backup/20200721-234619.ngwbackup
If you are restoring backup which made from some previous version, it may require to apply migrations. The process of applying migrations is described in «Backup and restore» section. Follow instruction from there, and then start NextGIS Web service again:
# systemctl start ngw.service