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
    Commented Dec 2, 2019 at 18:48

1 Answer 1


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.

  • 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 ? Commented Dec 6, 2019 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. Commented Dec 6, 2019 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 Commented Dec 6, 2019 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. Commented Dec 6, 2019 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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