[id=registry-sql-backup]
= Backing up {registry} PostgreSQL storage

When using storage in a PostgreSQL database, you must ensure that the data stored by {registry} is backed up regularly.

https://www.postgresql.org/docs/12/backup-dump.html[SQL Dump] is a simple procedure that works with any PostgreSQL installation.
This uses the https://www.postgresql.org/docs/12/app-pgdump.html[pg_dump] utility to generate a file with SQL commands that you can use to recreate the database in the same state that it was in at the time of the dump.

`pg_dump` is a regular PostgreSQL client application, which you can execute from any remote host that has access to the database.
Like any other client, the operations that can perform are limited to the user permissions.

.Procedure
* Use the `pg_dump` command to redirect the output to a file:
+
[source,bash]
----
 $ pg_dump dbname > dumpfile
----
+
You can specify the database server that `pg_dump` connects to using the `-h host` and `-p port` options.

* You can reduce large dump files using a compression tool, such as gzip, for example:
+
[source,bash]
----
 $ pg_dump dbname | gzip > filename.gz
----

.Additional resources
* For details on client authentication, see the https://www.postgresql.org/docs/12/client-authentication.html[PostgreSQL documentation].

ifdef::apicurio-registry[]
* For details on importing and exporting registry content, see https://www.apicur.io/registry/docs/apicurio-registry/2.0.0.Final/getting-started/assembly-managing-registry-artifacts-api.html[Managing Apicurio Registry content using the REST API].
endif::[]
ifdef::service-registry[]
* For details on importing and exporting registry content, see link:{LinkManagingContentUsingRESTAPI}[{NameManagingContentUsingRESTAPI}].
endif::[]
