1

I use the PostGIS extension on my database. The thing is when I do a backup and then a restore, all the PostGIS functions give a warning during the restore process, because the functions already exist, as the extension is already installed.

I have to scroll through all the warning to make sure there isn't a real error.

So what is the right way to backup / restore, so I can have a clean restore process?

  • Why is the extension already installed on the restoration target? Is the data already present there too? – jjanes Dec 2 '19 at 18:48
0

The best solution is to restore into a database that does not have PostGIS installed yet.

If PostGIS is installed in the template1 database, use template0 to create the new database.

| improve this answer | |
  • But this will result on the same effect as install the extension? Specially if later you want to replace the extension for a newer version. Can you remove and install a new one ? – Juan Carlos Oropeza Dec 6 '19 at 14:46
  • The dump contains a statement like CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;. So restoring the dump will create the extension. – Laurenz Albe Dec 6 '19 at 14:50
  • But then even if extension doesn't exist I will get the same error ? I will try and let you know. I think the only other way would be I uninstall the extension before do the backup and then reinstall – Juan Carlos Oropeza Dec 6 '19 at 15:00
  • Dropping the extension in the original database would drop all columns that use PostGIS data types. All you need is the extension files installed at the destination so that the CREATE EXTENSION succeeds. – Laurenz Albe Dec 6 '19 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.