Kotva |
---|
| trezorpostcompressparpg |
---|
| trezorpostcompressparpg |
---|
|
TrezorPostCompressPar - optional parameter, used for the program specified by the parameter TrezorPostCompressCmd. It can contain optional text and predefined macros to be replaced before running the program:- #ID# - is replaced by depository database ID (e.g. 5).
- #OID# - is replaced by OID (object identifier) of the depository database (OID is related to the name of the directory containing the respective database inside PostgreSQL tablespace).
- #OID0#, #OID1#, #OID2#, etc - is replaced by OIDs (object identifiers) of databases representing respective depository database segments 0, 1, 2, etc.
- #TREZOR# - is replaced by the depository database name (e.g. Test_TREZOR_5).
- #TREZOR0#, #TREZOR1#, #TREZOR2#, etc - is replaced by the database name representing the respective depository database segments.
An example of a batch file used to perform a depository database maintenance and export as well as the export of trezors table located in the archive database MyApp.Archiv. The batch file requires as a parameter the name of the depository database, which can be provided by setting the TrezorPostCompressPar parameter to value #TREZOR#.
rem Target directory for exports
set MyDir=D:\Trezors_export\
rem Set PGPASSWORD to password assigned to D2000 user
set PGPASSWORD=%D2000_DBPASS%
set PGUSER=%D2000_DBUSER%
rem Set PATH to PostgreSQL installation (version-dependent)
set PATH=%PATH%;c:\Program Files\PostgreSQL\13\bin
rem export of table trezors from the archive database
pg_dump -Fc -U %D2000_DBUSER% -f "%MyDir%\MyApp_arc_trezors.dmp" --table \"trezors\" MyApp.Archiv >> %MyDir%\%1.log
rem permit write access to depository database and cluster the data table
echo alter database "%1" set default_transaction_read_only=false | psql -S -U %D2000_DBUSER% MyApp.Archiv >> %MyDir%\%1.log
echo alter table data cluster on ix_data_rc | psql -S -U %D2000_DBUSER% %1 >> %MyDir%\%1.log
echo cluster data | psql -S -U %D2000_DBUSER% %1 >> %MyDir%\%1.log
rem set access to depository database back to read only
echo alter database "%1" set default_transaction_read_only=true | psql -S -U %D2000_DBUSER% MyApp.Archiv >> %MyDir%\%1.log
pg_dump -Fc -U %D2000_DBUSER% -f "%MyDir%\%1.dmp" %1 >> %MyDir%\%1.log
Example of an equivalent batch file for Linux:
#!/usr/bin/env bash
MyDir=/trezorbackup
MyArc=mes_tpd_archive_self
MyLog=$MyDir/$1.log
#path to pg_dump, psql etc
PATH=/usr/pgsql-11/bin:$PATH
#password for dba user
export PGPASSWORD=$D2000_DBPASS
export PGUSER=$D2000_DBUSER
#export of table trezors from the archive database
pg_dump -Fc -U $D2000_DBUSER -f "$MyDir/arc_trezors.dmp" --table \"trezors\" $MyArc >> $MyLog
#permit write access to depository database and cluster the data table
echo alter database \"$1\" set default_transaction_read_only=false | psql -S -U $D2000_DBUSER $MyArc >> $MyLog
echo alter table data cluster on ix_data_rc | psql -S -U $D2000_DBUSER "$1" >> $MyLog
echo cluster data | psql -S -U $D2000_DBUSER "$1" >> $MyLog
#set access to depository database back to read only
echo alter database \"$1\" set default_transaction_read_only=true | psql -S -U $D2000_DBUSER $MyArc >> $MyLog
#execute dump of depository database
pg_dump -Fc -U $D2000_DBUSER -f "$MyDir/$1.dmp" "$1" >> $MyLog