PostgreSQL Database recovery
All restore procedures should be consulted first with the Database Administrator/Owner in case an external PostgreSQL database is used.
Please note that this is just a quick guide to the pgAdmin tool. The latest documentation is always available on PostgreSQL's web pages.
Please check that the current backup files are available before you start with the restore procedures.
Preparation
Delete the current databases
On the database server, run the pgAdmin administration tool.
In the Object Browser window, double-click the YSoft SafeQ PostgreSQL server connection item and connect to the server.
Delete the current YSoft SafeQ databases:
SQDB6
SQDB6_IMS
SQDB6_YPS (if YSoft SafeQ Payment System is installed)
SQDB6_DWH (if Data Warehouse is in a separate database, the database might be deployed on a different server)
Create new databases
Right-click Databases > Create > Database
Create new databases with Owner set to postgres using the same names as the original ones:
SQDB6
SQDB6_IMS
SQDB6_YPS (if YSoft SafeQ Payment System is installed)
SQDB6_DWH (if Data Warehouse is in a separate database, the database might be deployed on a different server)
Restore the databases from the backup files
Restore the SQDB6 database from a backup file:
Right-click the database name and select the Restore... option.
Select your backup file.
Click Select.
A popup appears with information that the procedure ended successfully.
Click on More details to see the log.
Restore the SQDB6_IMS database from a backup file.
Also, restore the SQDB6_YPS database from a backup file (if YSoft SafeQ Payment System is installed).
Also restore the SQDB6_DWH database from a backup file (if Data Warehouse is in a separate database, the database might be deployed on a different server)
Reconfiguring the SQDB6 Database
If you have YSoft SafeQ 6 MU9 or later and if you have database user passwords in plain text (default configuration), run the following procedure on the SQDB6 database:
SELECT
cluster_mngmt.spu_recover_tenant_db_passwords();
If you have YSoft SafeQ 6 MU8 or older or if you have encrypted database user passwords, follow these manual steps:
Reconfigure tenantuser_1 user:
Find the tenantuser_1 password by running the following query on the SQDB6 database:
SELECT
db_pass
FROM
cluster_mngmt.tenants
WHERE
db_login=
'tenantuser_1'
Prepare the following query:
DO $body$
BEGIN
IF
NOT
EXISTS(
SELECT
*
FROM
pg_catalog.pg_user
WHERE
usename =
'@tenantUser@'
)
THEN
CREATE
ROLE @tenantUser@ LOGIN
PASSWORD
'@tenantPassword@'
;
ELSE
ALTER
ROLE @tenantUser@
WITH
PASSWORD
'@tenantPassword@'
;
END
IF;
END
$body$;
GRANT
ALL
ON
SCHEMA
@tenantSchema@
TO
@tenantUser@;
ALTER
USER
@tenantUser@
SET
search_path
TO
@tenantSchema@,cluster_mngmt,
PUBLIC
;
GRANT
ALL
ON
SCHEMA
cluster_mngmt
TO
@tenantUser@;
Replace variables with real values:
@tenantUser@ = tenantuser_1
@tenantPassword@ = tenantuser_1
password
from
step a (which must be decrypted).
@tenantSchema@ = tenant_1
Run the modified query on the SQDB6 database.
Reconfigure the dwhtenantuser_1 user:
Find the dwhtenantuser_1 password by running the following query on the SQDB6 database:
SELECT
db_pass
FROM
cluster_mngmt.tenant_warehouses
WHERE
db_login=
'dwhtenantuser_1'
Prepare the following query:
DO $body$
BEGIN
IF
NOT
EXISTS(
SELECT
*
FROM
pg_catalog.pg_user
WHERE
usename =
'@dwhTenantUser@'
)
THEN
CREATE
ROLE @dwhTenantUser@ LOGIN
PASSWORD
'@tenantPassword@'
;
ELSE
ALTER
ROLE @dwhTenantUser@
WITH
PASSWORD
'@tenantPassword@'
;
END
IF;
END
$body$;
GRANT
ALL
ON
SCHEMA
@dwhTenantSchema@
TO
@dwhTenantUser@;
ALTER
USER
@dwhTenantUser@
SET
search_path
TO
@dwhTenantSchema@,cluster_mngmt,
PUBLIC
;
GRANT
ALL
ON
SCHEMA
@tenantSchema@
TO
@dwhTenantUser@;
GRANT
ALL
ON
SCHEMA
cluster_mngmt
TO
@dwhTenantUser@;
Replace variables with real values:
@tenantSchema@ = tenant_1
@dwhTenantUser@ = dwhtenantuser_1
@tenantPassword@ = dwhtenantuser_1
password
from
step a (which must be decrypted).
@dwhTenantSchema@ = dwhtenant_1
Run the modified query on the SQDB6 database.
If you have more tenants, repeat the steps from section a. for all additional tenantuser_X and the steps from section b. for all corresponding dwhtenantuser_X
Reconfiguring the SQDB6 with data warehouse (DWH)
Basic information:
This section focuses on SQDB6 with data warehouse reconfiguration. Therefore, it is possible to skip this section if it is not relevant for the given situation.
Reconfiguring the database:
Follow the steps 1 (Preparation) and 2 (Delete the current databases) if not done already;
Run the following modified queries;
Inside SQDB6:
DO $body$ BEGIN IF NOT EXISTS(SELECT * FROM pg_catalog.pg_user WHERE usename =
'tenantuser_1'
) THEN CREATE ROLE tenantuser_1 LOGIN PASSWORD
'@tenantPassword@'
; ELSE ALTER ROLE tenantuser_1 WITH PASSWORD
'@tenantPassword@'
; END IF; END $body$;
GRANT ALL ON SCHEMA tenant_1 TO tenantuser_1;
ALTER USER tenantuser_1 SET search_path TO tenant_1,cluster_mngmt,PUBLIC;
GRANT ALL ON SCHEMA cluster_mngmt TO tenantuser_1;
Inside SQDB6_DWH:DO $body$ BEGIN IF NOT EXISTS(SELECT * FROM pg_catalog.pg_user WHERE usename =
'dwhtenantuser_1'
) THEN CREATE ROLE dwhtenantuser_1 LOGIN PASSWORD
'@tenantPassword@'
; ELSE ALTER ROLE dwhtenantuser_1 WITH PASSWORD
'@tenantPassword@'
; END IF; END $body$;
GRANT ALL ON SCHEMA dwhtenant_1 TO dwhtenantuser_1;
ALTER USER dwhtenantuser_1 SET search_path TO dwhtenant_1,cluster_mngmt,PUBLIC;
GRANT ALL ON SCHEMA cluster_mngmt TO dwhtenantuser_1;
Run validation tables
Inside SQDB6:SELECT cluster_mngmt.spu_clean_validator_tables();
Inside SQDB_DWH:DELETE from
public
.smartq_validator;
DELETE from cluster_mngmt.smartq_validator;
DELETE from dwhtenant_1.smartq_validator;
Repeat the steps for any additional tenants (if present)
Re-validating the Database
If you have YSoft SafeQ 6 MU9 or later, run the following procedure on the SQDB6 database:
SELECT
cluster_mngmt.spu_clean_validator_tables();
If you have SafeQ 6 MU8 or older, follow these manual steps:
Delete records from all validator-related tables.
delete
from
public
.smartq_validator;
delete
from
cluster_mngmt.smartq_validator;
Foreach tenant_id do:delete
from
tenant_%i.smartq_validator;
delete
from
dwhtenant_%i.smartq_validator;
Run DB Validator Tool.
Continue with the Finalization section.
Finalization
Clear the Cache on Spooler Controllers and Restart All Services
Cache on Spooler Controllers needs to be deleted after Database restore to avoid possible inconsistencies.
Delete Spooler Controller cache directory on all servers
Delete YSoft SafeQ Spooler Controller cache by deleting whole folder <SAFEQSPOC_DIR>\SpoolCache (e.g. c:\SafeQ6\SPOC\SpoolCache)
Start Management service again
Open the Services window (e.g. Start > Run > services.msc) and start the following services:
Start YSoft SafeQ Management Service
Verify the Spooler Controller cache recovery settings
Go to tab System > Configuration on YSoft SafeQ management interface and set orsCacheRecovery property to enabled.
In case of YSoft SafeQ Spooler Controller cache data corruption, cache can be manually deleted and all job-related metadata will be recovered from YSoft SafeQ Management Server.
If you omit this step, all jobs stored on the YSoft SafeQ Spooler Controller might be lost after the end of procedure.
Start the remaining services on all servers
Do not start YSoft SafeQ Spooler Controller Group Service manually. If YSoft SafeQ Spooler Controller is part of Spooler Controller group then this service will start automatically when its configuration is ready.
Start remaining YSoft services with Automatic startup type in no particular order
You can use the following PowerShell script to perform the task:
Get-Service *YSoft* | Where-Object {$_.Name -ne
'YSoftSQ-SPOCGS'
} | Start-Service
Verify the correct Spooler Controller functionality
Once the YSoft SafeQ Spooler Controller cache is deleted and YSoft SafeQ Spooler Controller services are running, verify the correct YSoft SafeQ Spooler Controller functionality according to the article YSoft SafeQ Spooler Controller Health Check.