Solving the Postgres Database Issue in Synology DSM

Power trip twice in an hour caused my DSM to enter into an error state. A few packages did not run successfully.
- Drive
- Contacts
- MailPlus
- Synology Application Services
- Synology Photos
- Video Station
It could not be repaired automatically and it state a dependency on the Synology Application Services. (Which I think it is Postgres SQL now). An trying to start it throws a pgsql-adapter.service is not available. These applications store metadata in Postgres Database.
Although not an expert on either the DSM OS or the Postgres DB, I know enough to start troubleshooting. So I enabled SSH and digged in.
Step 1: Check the logs
more /var/log/postgres.log
Compared it for the old logs.
xzcat /var/log/postgres.log.1.xz
Step 2: Backup the data
So data files are located (DSM 7.0 Beta) at /var/service/pgsql. So attached a USB HDD and then copy everything over.
cp -pr /var/service/pgsql /volumeUSB1/[shared folder]
Step 3: Attempt to Start the Service
Stupid me after many attempts, noticed that the service cannot be started due to a fatal error appearing in the logs.
su - postgres
The following start the application inline.
postgres
Or
pgctl start -D /var/service/pgsql
Step 4: Check the Error Logs
Luckly from logs, I spot something. A fatal log. It indicates that it complains that /tmp/synoCalendar cannot be access. So I check and it was indeed missing. (This is strange because I had uninstall the calendar app already.) So I manually create the directory try to start it. Presto it Work.
However trying to install the package it complaint that the pgsql-adapter.service is not available. So since I cannot find the service startup, (there is no synoservice in DSM7.0), I executed the standard Window maneuver. Restart. It worked!