пятница, 24 марта 2023 г.

ipsecadd

# ipsecadd_sbercloud
:local ipsecName "sbercloud";
:local ipsecComment "$ipsecName";
:local peerAddr "89.232.179.63";
:local peerLocalAddr "213.33.195.92";
:local ipsecSecret "asdfasfasdfasfasdf";
:local srcList [:toarray "192.168.1.0/24"];
:local dstList [:toarray "192.168.5.0/24"];

:if ([:len [/ip/ipsec/policy/find where comment="$ipsecName"]] > 0) do={/ip ipsec policy remove [find comment~"$ipsecComment"]}
:if ([:len [/ip/ipsec/identity/find where comment="$ipsecName"]] > 0) do={/ip ipsec identity remove [find comment~"$ipsecComment"]}
:if ([:len [/ip/ipsec/proposal/find where name="$ipsecName"]] > 0) do={/ip ipsec proposal remove $ipsecName}
:if ([:len [/ip/ipsec/peer/find where name="$ipsecName"]] > 0) do={/ip ipsec peer remove $ipsecName}
:if ([:len [/ip/ipsec/profile/find where name="$ipsecName"]] > 0) do={/ip ipsec profile remove $ipsecName}
:if ([:len [/ip/firewall/raw/find where comment="$ipsecName"]] > 0) do={/ip firewall raw remove [find comment~"$ipsecComment"]}
:if ([:len [/ip/route/find where comment="$ipsecName"]] > 0) do={/ip route remove [find comment~"$ipsecComment"]}

/ip ipsec profile add dh-group=modp2048 enc-algorithm=aes-128 hash-algorithm=sha256 nat-traversal=yes name=$ipsecName
/ip ipsec peer add address=$peerAddr local-address=$peerLocalAddr name=$ipsecName profile=$ipsecName comment="$ipsecComment vrrp" exchange-mode=ike2 disabled=yes
/ip ipsec proposal add name=$ipsecName lifetime=1h auth-algorithms="" enc-algorithms=aes-128-gcm pfs-group=modp2048
/ip ipsec identity add peer=$ipsecName secret=$ipsecSecret comment=$ipsecComment
:foreach dstAddr in $dstList do={
  /ip firewall raw add comment=$ipsecComment action=notrack chain=prerouting disabled=no dst-address=0.0.0.0/0 src-address=$dstAddr place-before=*0;
  /ip firewall raw add comment=$ipsecComment action=notrack chain=prerouting disabled=no dst-address=$dstAddr src-address=0.0.0.0/0 place-before=*0;
  :foreach srcAddr in $srcList do={
    /ip ipsec policy add dst-address=$dstAddr level=unique peer=$ipsecName proposal=$ipsecName src-address=$srcAddr tunnel=yes comment=$ipsecComment
  }
/ip route add distance=1 dst-address=$peerAddr gateway=213.33.195.81 pref-src=$peerLocalAddr routing-table=902-beeline comment=$ipsecName
/ip route add distance=1 dst-address=$peerAddr gateway=213.33.195.81 pref-src=$peerLocalAddr routing-table=main comment=$ipsecName
}

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

пятница, 17 марта 2023 г.

PXE-E51

Помогло настроить порт на свиче:
interface GigabitEthernet0/2
 description srv
 switchport access vlan 21
 switchport mode access
 spanning-tree portfast
 spanning-tree bpduguard enable

end


Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

четверг, 2 марта 2023 г.

Обновление сертификата letsencrypt на микротике

Включаем доступ на порту 80 (нужен чтобы летсэнкрипт мог проверить)
Обновляем сертификат
закрываем доступ на порту 80
Для этого пометил правила в фаерволе коментарием 

:local dnsName r-gw1.ratners.ru
/ip/service/enable www
/ip/firewall/filter/enable [ find where comment="letsencrypt" ]
/certificate enable-ssl-certificate dns-name=$dnsName
/ip/service/disable www
/ip/firewall/filter/disable [ find where comment="letsencrypt" ]
 
Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

среда, 1 марта 2023 г.

Скрипт создания IPSEC тунеля на микротике

# ipsecadd_atappc
:local ipsecName "atappc";
:local ipsecComment "$ipsecName";
:local peerAddr "1.2.88.186";
:local peerLocalAddr "2.3.195.93";
:local ipsecSecret "54KD1ekHcc3uP2ChqwlKCDlTx";
:local srcList [:toarray "192.168.0.0/22,192.168.7.0/24"];
:local dstList [:toarray "192.168.126.0/24,192.168.135.0/24"];

# удаляем старое
:if ([:len [/ip/ipsec/policy/find where comment="$ipsecName"]] > 0) do={/ip ipsec policy remove [find comment~"$ipsecComment"]}
:if ([:len [/ip/ipsec/identity/find where comment="$ipsecName"]] > 0) do={/ip ipsec identity remove [find comment~"$ipsecComment"]}
:if ([:len [/ip/ipsec/proposal/find where name="$ipsecName"]] > 0) do={/ip ipsec proposal remove $ipsecName}
:if ([:len [/ip/ipsec/peer/find where name="$ipsecName"]] > 0) do={/ip ipsec peer remove $ipsecName}
:if ([:len [/ip/ipsec/profile/find where name="$ipsecName"]] > 0) do={/ip ipsec profile remove $ipsecName}
:if ([:len [/ip/firewall/raw/find where comment="$ipsecName"]] > 0) do={/ip firewall raw remove [find comment~"$ipsecComment"]}

# создаём новое
/ip ipsec profile add dh-group=modp1024 enc-algorithm=aes-256 nat-traversal=yes name=$ipsecName
/ip ipsec peer add address=$peerAddr local-address=$peerLocalAddr name=$ipsecName profile=$ipsecName comment="$ipsecComment vrrp"
/ip ipsec proposal add name=$ipsecName enc-algorithms=aes-256-cbc lifetime=1h  pfs-group=modp1536
/ip ipsec identity add peer=$ipsecName secret=$ipsecSecret comment=$ipsecComment
:foreach dstAddr in $dstList do={
  /ip firewall raw add comment=$ipsecComment action=notrack chain=prerouting disabled=no dst-address=0.0.0.0/0 src-address=$dstAddr place-before=0;
  /ip firewall raw add comment=$ipsecComment action=notrack chain=prerouting disabled=no dst-address=$dstAddr src-address=0.0.0.0/0 place-before=0;
  :foreach srcAddr in $srcList do={
    /ip ipsec policy add dst-address=$dstAddr level=unique peer=$ipsecName proposal=$ipsecName src-address=$srcAddr tunnel=yes comment=$ipsecComment;
  }
}

среда, 12 октября 2022 г.

hyper-v manager standalone server

#on server
#Enable-PSRemoting
#Enable-WSManCredSSP -Role server

$ethint="Ethernet"
$hvservername="r-hv1"
$hvserverip="192.168.126.50"

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Tools-All -All
Set-NetConnectionProfile -InterfaceAlias $ethint -NetworkCategory Private
Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "`n"$hvserverip"`t"$hvservername
winrm quickconfig
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $hvservername
Enable-WSManCredSSP -Role client -DelegateComputer $hvservername
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\" -Name 'CredentialsDelegation'
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\" -Name 'AllowFreshCredentialsWhenNTLMOnly' -PropertyType DWord -Value "00000001"
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\" -Name 'ConcatenateDefaults_AllowFreshNTLMOnly' -PropertyType DWord -Value "00000001"
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\" -Name 'AllowFreshCredentialsWhenNTLMOnly'
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\AllowFreshCredentialsWhenNTLMOnly\" -Name '1' -Value "wsman/$hvservername"

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

пятница, 16 сентября 2022 г.

Самоподписанный сертификат сроком на 10 лет

New-SelfSignedCertificate `
-DnsName "r-hv1.r.ratners.online" `
-KeyAlgorithm RSA `
-KeyLength 2048 `
-CertStoreLocation "Cert:\LocalMachine\My" `
-NotAfter (Get-Date).AddYears(10)
 
Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

четверг, 15 сентября 2022 г.

1C Сброс пароля с postgresql

Сохраняем скрипт.
Запускаем с указанием имени БД
Скрипт переименовывает таблицу v8users и файл users.usr и предлагает запустить 1С конфигуратор.
Запускаем конфигуратор, после этого даём скрипту продолжить.
Он возвращает на место таблицу и файл.

[CmdletBinding()]
param(
    [String]$dbname="",
    [String]$PG_DIR='C:\Program Files\PostgresPro 1C\9.4',
    [String]$PSQL="$PG_DIR\bin\psql.exe",
    [String]$dbserver='localhost',
    [String]$dbuser='postgres',
    [String]$dbpassword='pass'
)

Write-Verbose -message dbname=$dbname
Write-Verbose -message PSQL=$PSQL
Write-Verbose -message dbserver=$dbserver
Write-Verbose -message dbuser=$dbuser
Write-Verbose -message dbpassword=$dbpassword

$env:PGPASSWORD = $dbpassword
$env:PGUSER = $dbuser
$env:PGHOST = $dbserver

Write-Verbose -message "Checking -dbname is set $dbname"
if ($dbname -eq "") {
Write-Host "-dbname not set"
exit
}

Write-Verbose -message "Rename table v8users"
& $PSQL --dbname $dbname -c "ALTER TABLE v8users RENAME TO v8users_bak;"
Write-Verbose -message "Rename file users.usr"
& $PSQL --dbname $dbname -c "UPDATE Params SET FileName='users.usr_bak' WHERE FileName='users.usr';"
Write-Host "Run 1C Configurator and press any key and enter"
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');

Write-Verbose -message "Drop table v8users"
& $PSQL --dbname $dbname -c "DROP TABLE v8users;"
Write-Verbose -message "Rename table v8users_bak -> v8users"
& $PSQL --dbname $dbname -c "ALTER TABLE v8users_bak RENAME TO v8users;"
Write-Verbose -message "Rename file users.usr_bak -> users.usr"
& $PSQL --dbname $dbname -c "UPDATE Params SET FileName='users.usr' WHERE FileName='users.usr_bak';"

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

четверг, 1 сентября 2022 г.

Обновляем iDrac

-g : use TFTP download process for firmware update (use with -u)
-u : perform firmware update operation (used with -g)
-a : specifies TFTP server IP address used for firmware image (used with -g)
-d : specifies source path where firmware image exists (default is local)
-s : query for current firmware update process status
-r : rollback to the standby firmware

по ftp
racadm fwupdate -f 10.80.111.110 ftp FtpFtp -d /pub/tftproot/283/firmimg.d7

по tftp
racadm fwupdate -g -u -a 10.80.111.110 -d /283

Полезные команды
racadm getversion
racadm fwupdate -s

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

четверг, 25 августа 2022 г.

Windows синхронизация времени и наблюдение за расхождением

Посмотреть текущий статус, от туда же возьмём имя сервера с которым будем сравнивать своё время
w32tm /query /status

Примерно раз в секунду сравнивает локальное время со временем сервера, возвращает разницу в секундах.
w32tm /stripchart /dataonly /computer:ИМЯСЕРВЕРА

После этой команды видно как разница в локальном времени и времени сервера начинает сокращаться.
w32tm /resync /rediscover

Установить список серверов с которыми следует синхронизировать время.
w32tm.exe /config /manualpeerlist:"time.nist.gov,0x8 time.windows.com,0x8 pool.ntp.org,0x8" /syncfromflags:manual /reliable:yes /update

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

пятница, 29 апреля 2022 г.

Распковать сто вложенных архивов

Разархивировать разархивированный файл до тех пор пока в имени разархивированного файла есть tar.gz

arc=$(tar xzfv /home/admin/archive.tar.gz)
while [[ $arc =~ "tar.gz" ]]; do arc=$(tar xzfv $arc) done

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

пятница, 14 января 2022 г.

Centos 7 L2TP xl2tpd strongswan

С Centos 7 есть проблема с настройкой впн подключения с помощью NetworkManager, т.к. он использует libreswan, а тот, в свою очередь, перестал поддерживать устаревшие алгоритмы шифрования: 3des, modp1024. Можно настроить постоянное подключение по l2tp как это сделать текст ниже:


# yum -y install epel-release

# yum -y install strongswan xl2tpd

# systemctl enable strongswan xl2tpd


VPN_SERVER='vpn.dom.ru' # адрес сервера

VPN_IPSEC_PSK='larhe4rtdfkjgh8340' # общий l2tp секрет

VPN_USER='user1' # имя пользователя

VPN_PASSWORD='P@ssword1' # пароль пользователя

VPN_CONN='dom' # имя подключения


cat > /etc/strongswan/ipsec.conf <<EOF

# ipsec.conf - strongSwan IPsec configuration file

conn %default

  ikelifetime=60m

  keylife=20m

  rekeymargin=3m

  keyingtries=0

  keyexchange=ikev1

  authby=secret

  ike=3des-sha1-modp1024,aes128-sha1-modp1024!

  esp=3des-sha1-modp1024,aes128-sha1-modp1024!


conn $VPN_CONN

  auto=start

  type=transport

  left=%defaultroute

  rightprotoport=17/1701

  right=$VPN_SERVER

  rightid=%any

  ike=3des-sha1-modp1024!

  esp=3des-sha1!

EOF


cat > /etc/strongswan/ipsec.secrets <<EOF

: PSK "$VPN_IPSEC_PSK"

EOF

chmod 600 /etc/strongswan/ipsec.secrets


cat > /etc/xl2tpd/xl2tpd.conf <<EOF

[lac $VPN_CONN]

lns = $VPN_SERVER

ppp debug = no

pppoptfile = /etc/ppp/options.l2tpd.client

length bit = yes

redial = yes

autodial = yes

EOF


cat > /etc/ppp/options.l2tpd.client <<EOF

ipparam $VPN_CONN

ipcp-accept-local

ipcp-accept-remote

refuse-eap

require-chap

noccp

noauth

mtu 1280

mru 1280

noipdefault

usepeerdns

connect-delay 5000

name "$VPN_USER"

password "$VPN_PASSWORD"

EOF

chmod 600 /etc/ppp/options.l2tpd.client


cat > /etc/ppp/ip-up.local << EOF

#!/bin/bash

PATH=/sbin:/usr/sbin:/bin:/usr/bin

export PATH

LOG=/tmp/ip-up.local.log

DSTNETS="10.4.108.0/24 10.32.0.0/16 10.33.70.0/24 10.70.1.0/24 10.80.0.0/16 10.88.0.0/16 10.89.0.0/16 10.90.0.0/24 10.91.0.0/16 10.208.1.0/24 10.254.0.0/16"

DEV=\$1

TTY=\$2

SPEED=\$3

LOCALIP=\$4

REMOTEIP=\$5

IPPARAM=\$6


f_$VPN_CONN () {

  for i in \$DSTNETS; do

  ip route add \$i dev \$DEV

  done

}

case \$IPPARAM in

"$VPN_CONN")

  f_$VPN_CONN

  ;;

"*")

  ;;

esac

exit 0

EOF

chmod a+x /etc/ppp/ip-up.local


systemctl restart strongswan xl2tpd


Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

среда, 15 декабря 2021 г.

Список баз 1С для всех

файл который надо положить в %appdata%\1c\1cestart
\\corp.org.ru\1c\cfg\1cestart.cfg
CommonCfgLocation= \\corp.dom.ru\1c\cfg\1CESCmn.cfg
UseHWLicenses=0
AppAutoInstallLastVersion=0
файл в котором перечислены все ИБ
\\corp.dom.ru\1c\cfg\1cescmn.cfg
CommonInfoBases=\\corp.dom.ru\1c\v8i\org-buh-arc-20180831.v8i
CommonInfoBases=\\corp.dom.ru\1c\v8i\org-buh.v8i
CommonInfoBases=\\corp.dom.ru\1c\v8i\org-doc.v8i
CommonInfoBases=\\corp.dom.ru\1c\v8i\org-zup-arc-20180702.v8i
CommonInfoBases=\\corp.dom.ru\1c\v8i\org-zup.v8i
файл с информацией для генерации файлов v8i
\\corp.dom.ru\1c\cfg\v8i_utf8.csv
IB;SRV;IBFN;ORG;CONF;Prod;Description
org-buh-arc-20180831;org-v-1c;Организация Бух Архив 20180831;Организация;Бух;Архив;20180831
org-buh;org-v-1c;Организация Бух;Организация;Бух;;
org-doc;org-v-1c;Организация СЭД;Организация;СЭД;;
org-zup-arc-20180702;org-v-1c;Организация ЗУП Архив 20180702;Организация;ЗУП;Архив;20180702
org-zup;org-v-1c;АТИС ЗУП;АТИС;ЗУП;;
скрипт который генерит файлы v8i. группы в АД, назначает соответствующие разрешения
1c_v8igen.ps1
#$VerbosePreference = "Continue"
$IBListCSV = "\\corp.dom.ru\1c\cfg\v8i_utf8.csv"
$v8iPath = "\\corp.dom.ru\1c\v8i"
$1CECmn = "\\corp.dom.ru\1c\cfg\1CESCmn.cfg"
$CsvEncoding = "utf8"
Write-Verbose -message "$IBListCSV"
Write-Verbose -message "$v8iPath"
$OUPath = "ou=v8i,ou=1c,ou=Группы доступа,dc=corp,dc=org,dc=ru"

$Template = '[%IBFN%]
Connect=Srvr="%SRV%";Ref="%IB%";
Folder=/
External=0
ClientConnectionSpeed=Normal
App=Auto
WA=1
Version=8.3
AppArch=x86
'

Write-Verbose -message "ActiveDirectory module check "
if (Get-Module -ListAvailable -Name ActiveDirectory) {
    Write-Verbose -message "ActiveDirectory module installed"
}
else {
    Write-Host "ActiveDirectory module not installed try"
Write-Host "Install-WindowsFeature -Name ""RSAT-AD-PowerShell"" -IncludeAllSubFeature"
exit
}

$IBList = Import-Csv -Path "$IBListCSV" -Encoding $CsvEncoding -Delimiter ";"
$v8iAll = "$($v8iPath)\_All.v8i"
Out-File -Encoding utf8 -FilePath "$v8iAll"
Out-File -Encoding utf8 -FilePath "$1CECmn"

ForEach ($IB in $IBList) {
Write-Verbose -message $IB.IBFN
$NewTemplate = $Template -replace "%IBFN%", $IB.IBFN
Write-Verbose -message $IB.SRV
$NewTemplate = $NewTemplate -replace "%SRV%", $IB.SRV
Write-Verbose -message $IB.IB
$NewTemplate = $NewTemplate -replace "%IB%", $IB.IB
Write-Verbose -message "$v8i"
$v8i = "$($v8iPath)\$($IB.IB).v8i"
$NewTemplate | Out-File -Encoding utf8 -FilePath $v8i
$NewTemplate | Out-File -Append -Encoding utf8 -FilePath $v8iAll
"CommonInfoBases=$v8i" | Out-File -Append -Encoding utf8 -FilePath $1CECmn
$GroupName = "DL_v8i_$($IB.IB)_RO"
Write-Verbose -message "$chekGroup"
if ( $(Get-ADGroup -LDAPFilter "(sAMAccountName=$GroupName)") -eq $null ) {
Write-Verbose -message "Create $GroupName"
New-ADGroup -Name $GroupName -Path $OUPath -GroupScope Global -GroupCategory Security
}
Write-Verbose -message "Update $GroupName"
Set-ADGroup -Identity $GroupName -Replace @{
info="Path=$v8i; aclType=Read"
Description = "$($IB.IBFN)"
}
Write-Verbose -message "$GroupName addMember DL_v8i_all"
Add-ADGroupMember -Identity $GroupName -Members DL_v8i_all
Write-Verbose -message "DL_1c_list addMember $GroupName"
Add-ADGroupMember -Identity DL_1c_list -Members $GroupName
Write-Verbose -message "Get-ACL $v8i"
$acl = Get-Acl -Path $v8i
Write-Verbose -message "Setup Permissions"
$permission = "MLG\$GroupName", 'Read', 'Allow'
Write-Verbose -message "Setup Rule"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($permission)
Write-Verbose -message "Setup Acl"
$acl.SetAccessRule($rule)
Write-Verbose -message "Save Acl to $v8i"
$acl | Set-Acl -Path $v8i
}

Что проиcходит?
Скрипт читает CSV
(IB - берёт из колонки IB csv файла)
Создаёт файл IB.v8i 
Создаёт группу в АД с именем DL_v8i_IB_read
Назначает этой группе разрешение read на файл v8i
Добавляет группу в другие группы.
Осталось создать GPO которое будет заменять файл %appdata%\1c\1cestart\1cestart.cfg файлом \\corp.org.ru\1c\cfg\1cestart.cfg

Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090

Dell MD32xx Disk Group failed

Случилось, видимо из-за того что не был соблюдён порядок включения полок
Все дисковые группы которые были на полке 1220, подключенной к 3200, были в состоянии Failed.
Все жёсткие диски в состоянии Optimal
Ни один не вынимался и не менялись местами.
Решил попробовать "возродить" дисковую группу с помощью команды:
Возвродить дисковую группу.
smcli -n ИмяПолки -c "revive diskgroup[ИмяГруппы];"
Получить список полок:
smcli -d -i

После этого группа перешла в режим восстановления и диск снова стал доступен на кластере. 

1С. Восстановление из резервной копии бд postgres

# .\1c_pg_restore.ps1 -verbose -dbname buh-new-20211130-1129 -dumpfile e:\tmp\buh-new__20211130-112901.backup

[CmdletBinding()]
param(
    [String]$dbname="",
    [String]$dumpfile="",
    [String]$PG_DIR='C:\Program Files\PostgreSQL 1C\12\',
    [String]$CREATEDB="$PG_DIR\bin\createdb.exe",
    [String]$PGRESTORE="$PG_DIR\bin\pg_restore.exe",
    [String]$PSQL="$PG_DIR\bin\psql.exe",
    [String]$dbserver='localhost',
    [String]$dbuser='postgres',
    [String]$dbpassword='password'
)

Write-Verbose -message dbname=$dbname
Write-Verbose -message CREATEDB=$CREATEDB
Write-Verbose -message PGRESTORE=$PGRESTORE
Write-Verbose -message PSQL=$PSQL
Write-Verbose -message dbserver=$dbserver
Write-Verbose -message dbuser=$dbuser
Write-Verbose -message dbpassword=$dbpassword

$env:PGPASSWORD = $dbpassword
$env:PGUSER = $dbuser
$env:PGHOST = $dbserver

Write-Verbose -message "Check -dbname is set $dbname"
if ($dbname -eq "") {
Write-Host "-dbname not set"
exit
}
Write-Verbose -message "Check -dumpfile is set $dumpfile"
if ($dumpfile -eq "") {
Write-Host "-dumpfile not set "
exit
} else {
Write-Verbose -message "Check existance $dumpfile"
if (!(Test-Path $dumpfile)) {
Write-Host $dumpfile does not exist
exit
}
}
Write-Verbose -message "Check existance $dbname"
# $dblist = &$PSQL --host=$dbserver --username=$dbuser --dbname $dbname -c "\q" 2>&1
$dblist = &$PSQL --dbname $dbname -c "\q" 2>&1
if ($LastExitCode -eq 0) {
Write-Host "$dbname alredy exists, exiting"
exit
}
Write-Verbose -message "$dbname Creating db"
$createdbparams = "--encoding=utf8 --template=template1 --locale=ru_RU.UTF-8 --lc-collate=ru_RU.UTF-8 --lc-ctype=ru_RU.UTF-8 --encoding=UTF8"
$result = & $CREATEDB $dbname $createdbparams
if ($LastExitCode -ne 0) {
Write-Host "$dbname can not create, exiting"
exit
}
Write-Verbose -message "$dbname restoring db $PGRESTORE -d $dbname"
$result = & $PGRESTORE --dbname=$dbname $dumpfile 2>&1
if ($LastExitCode -ne 0) {
Write-Host "$dbname not restored, exiting"
exit
}
Write-Verbose -message "$dumpfile restored to $dbname"


Ратнер Арсений, arsenyratner@gmail.com, 7 985 273 2090