This guide shows how to restore an EventSentry .backup file (created with pg_dump, see KB235) onto a separate, dedicated PostgreSQL server - for example, to access archived/historical data without risking disk space or performance issues on your production EventSentry server. Once restored, the database can be connected to the Web Reports as an additional profile, letting you switch between your live and archive databases from the same Web Reports interface.
Important Note on Database Size: A pg_dump backup file is compressed, so the restored database will be significantly larger than the backup file itself - often 10-40x or more, depending on how compressible your data is. To estimate your own expansion ratio, compare a recent backup file's size to your live database's actual size (visible in the Web Reports > Tools > Database Usage), and apply that same ratio to the archive file you're restoring. Provision the new server with headroom above your estimate.
Download the standalone PostgreSQL installer (matching the major version used to create your backup) from the official site: Download PostgreSQL
Run a default installation. Make note of the password you set for the postgres superuser - you'll need it for every command below.
By default, a fresh PostgreSQL install only accepts local connections. Edit these two files located in C:\Program Files\PostgreSQL<version>\data:
postgresql.conf > Confirm this setting allows listening beyond localhost:listen_addresses = '*'
pg_hba.conf > Add lines at the end of the file allowing your production server's IP to connect (replace PRODUCTION_ES_SERVER_IP and match the auth method already used elsewhere in the file, typically scram-sha-256 or md5):
Restart the PostgreSQL service (postgresql-x64-version) so both changes take effect.
Creating this role before restoring the backup means the permissions embedded in the backup file apply automatically during restore - saving you a manual permissions step afterward. In an elevated Command Prompt:
Note: The eventsentry_web user is what the Web Reports use to read data, and the eventsentry_svc user is what the EventSentry collector service uses to write data.
Choose a name that won't collide with your production database (this example uses EventSentry_Archive):
1 | "C:\Program Files\PostgreSQL\<version>\bin\psql.exe" -h localhost -U postgres -c "CREATE DATABASE \"EventSentry_Archive\""
|
1 | "C:\Program Files\PostgreSQL\<version>\bin\pg_restore.exe" -h localhost -U postgres -d EventSentry_Archive -v C:\path\to\your\es_database.backup
|
Restore time depends on the backup size - for large archives this can take a while. You'll see a long stream of creating TABLE, creating INDEX, and creating FK CONSTRAINT messages; this is normal. Do not interrupt this process.
In the Web Reports, go to Settings > Profile Editor > New Profile and enter:
Click Test Connection, then Submit. You can now switch between your live and archive databases using the profile dropdown in the upper-left corner of the Web Reports. Check that the database is being successfully accessed in the Web Reports by going to Tools > Database Usage.
FATAL: no pg_hba.conf entry for host...
The new server hasn't been configured to accept connections from your production server yet. Revisit Step 2 - and confirm the IP in pg_hba.conf matches your production server exactly, and that you restarted the PostgreSQL service after editing both files. If you still can't connect after this, check that Windows Firewall on the new server allows inbound TCP 5432 from your production server's IP.
Permission denied for schema eventsentry
This means the eventsentry_web/svc role didn't exist when the backup was restored, so the permission grants embedded in the backup were skipped. Grant permissions manually:
1 | "C:\Program Files\PostgreSQL\<version>\bin\psql.exe" -h localhost -U postgres -d EventSentry_Archive -c "GRANT USAGE ON SCHEMA eventsentry TO eventsentry_web; GRANT SELECT ON ALL TABLES IN SCHEMA eventsentry TO eventsentry_web; GRANT SELECT ON ALL SEQUENCES IN SCHEMA eventsentry TO eventsentry_web;"
|
To avoid this next time, create the role before restoring (Step 3 before Step 5).
Pg_restore: error: could not execute query: ERROR: role "eventsentry_web/svc" does not exist during restore
This is expected if the database roles were not created. Check step 3.
Column ... does not exist when browsing the archive profile in Web Reports > Tools > Database Usage.
This means the archived database's schema is older than what your current Web Reports version expects since the schema evolves across EventSentry releases. To fix it, update the archive's schema using EventSentry's built-in Database Wizard:
Manage your cookie preferences below:
To learn more about our use of cookies, please see our
Privacy Policy.