Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.

...

rem Target directory for exports
set MyDir=D:\Trezors_export\
rem Set PGPASSWORD to password assigned to postgres user during installation
set PGPASSWORD=MyPostgresPassword
set PATH=%PATH%;c:\Program Files\PostgreSQL\9.5\bin
rem export of table trezors from the archive database
pg_dump -Fc -U postgres -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 postgres MyApp.Archiv >> %MyDir%\%1.log
echo alter table data cluster on ix_data_rc | psql -S -U postgres %1 >> %MyDir%\%1.log
echo cluster data | psql -S -U postgres %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 postgres MyApp.Archiv >> %MyDir%\%1.log
pg_dump -Fc -U postgres -f "%MyDir%\%1.dmp" %1 >> %MyDir%\%1.log

Príklad ekvivalentného dávkového súboru pre platformu 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=***

#export of table trezors from the archive database
pg_dump -Fc -U dba -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 dba $MyArc >> $MyLog
echo alter table data cluster on ix_data_rc | psql -S -U dba "$1" >> $MyLog
echo cluster data | psql -S -U dba "$1" >> $MyLog

#set access to depository database back to read only
echo alter database \"$1\" set default_transaction_read_only=true | psql -S -U dba $MyArc >> $MyLog
#execute dump of depository database
pg_dump -Fc -U dba -f "$MyDir/$1.dmp" "$1" >> $MyLog