How can I recreate the default internal PostgreSQL database?

Article ID: 519
Category: Database
Applies to: 5.0 and later
Updated: 2024-10-15

If you experience data corruption, data loss, or accidentally delete files from the internal Postgres database, this guide will walk you through the steps to regenerate the internal Postgres database structure and recreate a fresh, empty EventSentry database.

Before proceeding with this guide, ensure that you back up the data14 directory. This guide will reset the database structure to a state equivalent to a fresh installation, resulting in the loss of all existing data.

1- Stop all EventSentry services

List of services (your installation may not have all services):

EventSentry
EventSentry Collector
EventSentry Database v14
EventSentry Heartbeat Monitor
EventSentry Network Services
EventSentry Web Reports
EventSentry ADMonitor

2- Move Data14 directory root files

Assuming EventSentry is installed in the default directory, copy/move the root files from
C:\Program Files\EventSentry\data14\ (just the root files, not subfolders) to a temporary location (e.g., a folder on your desktop). These files will be copied back later. The list of files you should have there:

3- Delete contents of the data14 folder

Delete all contents inside the folder C:\Program Files\EventSentry\data14 but DO NOT delete the folder itself. This saves us the trouble of setting permissions again.

4- Set permissions

Despite running the command with Administrator rights, PostgreSQL will set the access rights to the currently logged-in user. Grant full access to data14 for your user: Right-click on data14, select Properties, go to the Security tab, click Edit, then Add, search for your user, click OK, select Full Control, and click OK. It should look like this (in this example, the user is "John.Doe"):

5- Initialize the Database

Open a command prompt as Administrator and run the following command (adjust the directories if EventSentry is installed elsewhere):
"C:\Program Files\EventSentry\postgresql14\bin\initdb.exe" --encoding=UTF-8 -D "C:\Program Files\EventSentry\data14" -U postgres -A password -W
This command will initialize the PostgreSQL database. Note that you are setting a new password for the postgres user, write it down for future reference.

6- Copy Root Files Back

Copy the root files you moved in step 2 back to the data14 folder, overwriting if prompted.

7- Start the EventSentry Database Service

Start the EventSentry Database v14 service (only this service for now).

8- Open EventSentry Management Console

You may see an error about authentication failing for user "eventsentry_svc" - this is normal.

9- Initialize or Update Database

In the EventSentry management console, go to Actions > Primary Database (or the name of your primary database action if you changed it). In the right panel click on the Initialize or Update button.

10- Configuration Assistant

The Configuration Assistant will start. Click Next, enter the postgres user password set earlier and click Next again. Create passwords for eventsentry_svc and eventsentry_web, then click Next to initialize the EventSentry database. Click Finish when done.

11- Save configuration

From the top ribbon menu, click Save, or Save and Deploy if you have staged configuration enabled.

12- Start all services

Start all services from the Windows Service Manager or from the Services item in the EventSentry management console. Everything should now be up and running. You may also want to open Web Reports to complete the initial setup.



Try EventSentry on-premise

FREE 30-day evaluation

Download Now