PostgreSQL® Database Maintenance
Upgrade the Schema
PSQL_upgradeTo1.3.sql
upgrades
the schema to version 1.3. psql -f <upgrade_script.sql> [-U user] [-h database_host] [-p database_port] <database_name>
For example, to upgrade the schema to version 1.3, where the database server is installed on localhost with default port (5432), with the user (etm) and with the database name (winccoa), simply call:
psql -f PSQL_upgradeTo1.3.sql -U etm winccoa
You will then be asked for the password of the user `etm`. For more information about how to connect to the PostgreSQL® database, see (https://www.postgresql.org/docs/current/app-psql.html).
Create a Backup
Prerequisite: WinCC OA project is running and PostgreSQL® database is accessible.
- Open the command shell on Windows or a terminal window on Linux.
- Change to the following WinCC OA product directory /bin/pgsql/bin. If an environment variable is set to this directory under Windows, this is not necessary.
- Execute the following psql commands:
You must authenticate yourself (user = "etm" + your defined password for standard project creation or the default password for a "Legacy project"). If the command is executed successfully, the output is "<size/size> kB (100 %), 1/1 tablespacepg_basebackup -D <db_target_backup_directory> [-U admin_user] [-h database_host] [-p database_port] -Ft -z -c spread -R -P
Note: The <db_target_backup_directory> must be empty. It is recommended to set up a "Date+Time" folder in the directory.
Restore the backup
- Rename the following database file directory: <wincc oa project directory>db/wincc_oa/localdb/postgresql/16/pgdata and create an empty new pgdata directory.
- Open the command shell on Windows or a terminal window on Linux.
- Change to the following WinCC OA product directory
<winccoa product
directory>/<version>/bin/pgsql/bin.
Note: Note that if an environment variable is set to this directory under Windows, this is not necessary. Note also that the target "database_directory" must be empty. You must first move or delete your old, corrupted database.
- Execute the command for a managed database - see PostgreSQL® Database Overview
tar -xf <db_target_backup_directory>/base.tar.gz -C <db_file_target_directory> tar -xf <db_target_backup_directory>/pg_wal.tar.gz -C <db_file_target_directory>/pg_wal
- Execute the following two commands if you use a remote database:
pg_ctl start -D <db_file_target_directory>
-
pg_ctl promote -D <database_directory>
If a database restore has become necessary and the NextGen Archiver has buffered the data from the failure, the buffers are automatically rewritten to the database after a new database connection and the buffers are resolved.
You can find all required commands in the readme file <winccoa product directory>/<version>data/NGA/PostgreSQL/sql>/readme.md
systemctl
instead of pg_ctl start
.pg_ctl
is not included in the bin path under
Debian. You must use the /lib/postgresql/$version$/bin/pg_ctl full
path.