Best Practice for backing up the DB

What is the recommended best practice for creating backups of the entire keycloak DB (realms, users, configuration, etc) when the DB is an external RBD like postgres or mysql ?

The methods I’ve seen online for using with the keycloak.migration.* parameters to dump to a file works ok, but its not great for running in a scripted environment such as from a cronjob because the server never exits, it creates the backup and then just stays running. It would be nice if there was a way to use the admin REST API to export everything.

Is it just as safe to do a SQL DB dump with the native tools for the relational db thats being used, such as pg_dump or mysqldump ? In the event that the DB is lost, if we rebuild and recover from the DB backup, would keycloak notice that there was a loss?

There is not a lot of good documentation on backing up the system, at least not that I could find. Any help would be appreciated.

So long, I did not make any bad experience with using regular DB dumps when using them in recovery case. This is also the “official” advice. Do a regualar DB dump/backup using the tool(s) of your database.

I did it with Postgresql and MySql, both did work like expected.

1 Like