mediagis / nominatim-docker

100% working container for Nominatim
Creative Commons Zero v1.0 Universal
1.03k stars 434 forks source link

Backup and restore #522

Closed MatsGej closed 4 months ago

MatsGej commented 6 months ago

When I have initiated nominatim on my development postregsql database, can I backup the database and then restore the backup on my production postresql database. Could I do updates on the production version as well?

This is the github copilot response to the first part of this question: GitHub Copilot Yes, you can backup your development PostgreSQL database and restore it on your production PostgreSQL database. This is a common practice for migrating data and changes from a development environment to a production environment.

Here are the general steps you would follow:

Backup the development database. You can use the pg_dump tool to create a backup of your development database. Here's an example command:

pg_dump -U username -W -F t database_name > backup.tar This command will create a backup of the database_name database in the backup.tar file.

Restore the backup on the production database. You can use the pg_restore tool to restore the backup on your production database. Here's an example command:

pg_restore -U username -W -d database_name -1 backup.tar This command will restore the backup from the backup.tar file to the database_name database.

As for updates, yes, you can perform updates on the production database just like you would on the development database. However, it's generally recommended to first test any updates on a development or staging environment before applying them to the production environment.

Please note that the pg_dump and pg_restore commands must be run from the command line, not from within the psql or pgAdmin interface. Also, replace username and database_name with your actual PostgreSQL username and database name.

Remember to always have a recent backup of your production database before performing any major operations such as a restore or an update. This will allow you to recover your data in case something goes wrong.

############################ My comment on the second part of the question: You can always connect to a remote postgresql server from the development environment and do the updates from there, or run the docker it the production environment add do the updates from it.

############ Is this correct?

????????????????????????????????????? If this is correct, could not someone just regularly store a "standard" version backup of the database somewhere and avoid spending lots of time waiting for a planet generation to be completed. Thanks Mats

leonardehrenfried commented 4 months ago

I suggest using docker import/export for moving a container and/or volumes.