首页 > 解决方案 > 无法在 powershell 中运行 pg_basebackup

问题描述

我们正在尝试pg_basebackup在 Powershell 中的 Windows 上运行脚本。该命令似乎在 windows 命令行 ( cmd) 中有效,但在powershell某些机器上无效。我们以管理员身份运行 Powershell。有没有人遇到过这个?

以下是我们正在运行的命令:

pg_basebackup --host "localhost" --port "5432" --username="test" --password="testpassword" --progress --verbose -D "C:\test\master\base_backups\test"

标签: postgresqlpowershell

解决方案


尝试使用这个

# Put here your pg_basebackup file location
Set-Location "C:\PostgreSQL\9.6\bin" 
# Put Here your password
$env:PGPASSWORD = "testpassword" 
[string]$job = .\pg_basebackup --% -U test --progress --verbose -D "C:\test\master\base_backups\test"

结果将是$job可变的。


推荐阅读