How do I back up the built in EventSentry database?

Article ID: 235
Category: Database
Applies to: 2.93+
Updated: 2022-10-14

If you are using the built in EventSentry database, you can back it up using the "pg_dump.exe" utility. This is located by default in the EventSentry\postgresql14\bin folder.

You can create a batch file with the following contents:

1
2
3
@ECHO OFF
SET PGPASSWORD=your_postgres_account_password
"C:\Program Files\EventSentry\postgresql14\bin\pg_dump.exe" -h localhost -p 5432 -U postgres -F c -b -v -f "C:\backups\es_database.backup" EventSentry

*Please note: If you still use Postgres 9.6, pg_dump.exe will be in the "C:\Program Files (x86)\EventSentry\postgresql96\bin" folder instead

Right-click the batch file and choose Run As Administrator, and this will dump the entire database into a file that can be restored. The .backup file it produces can be backed up with your regular backup software as well.

Please see the reference link at the bottom of this article for more information regarding how to make this more automated.

To restore the database from a backup, run these commands from the command prompt after opening the command prompt using Run As Administrator:

1
2
"C:\Program Files\EventSentry\postgresql14\bin\psql.exe" -U postgres -c "CREATE DATABASE \"EventSentry\""
"C:\Program Files\EventSentry\postgresql14\bin\pg_restore.exe" -h localhost -U postgres -d EventSentry -v c:\backups\es_database.backup

*Please note: If you still use Postgres 9.6, psql.exe and pg_restore.exe will be in the "C:\Program Files (x86)\EventSentry\postgresql96\bin" folder instead