$date_rep = get-date -uformat "%A"
$catalogPOST = "C:\Program Files\PostgreSQL\10.15-4.1C\bin"
$userDB = "postgres"
# command save password for CMD
#SET 'PGPASSWORD = PostAdmin';
# command save password for powershell
$env:PGPASSWORD = 'PostAdmin';
cd $catalogPOST
$databases = .\psql.bat --% -U postgres -w -l -t -A
$databases = foreach ($database in $databases){[regex]::escape($database) -replace "\\\|.+$",""}
$databases = $databases | Select-String "^(?!.*postgres)"| Select-String "^(?!.*template)" | Select-String "^(?!.*Copy)" | Select-String "^(?!.*Perf_test)"# | Select-String "(\S*_\S*_\S*)"
foreach ($database in $databases)
{
$file_db = "D:\backUp\1c\Postgress\" + $date_rep + "_" +$database + ".sql"
cmd /c $catalogPOST\pg_dump.exe --file $file_db --host "localhost" --port "5432" --username $userDB --verbose --format=c --blobs $database
}
# cmd /c $catalogPOST\pg_restore.exe --host "localhost" --port "5432" --username $userDB --dbname "ksi" --verbose $file_db