Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL备份pg_转储无法与windows任务计划程序一起使用_Windows_Postgresql_Powershell_Scheduled Tasks - Fatal编程技术网

PostgreSQL备份pg_转储无法与windows任务计划程序一起使用

PostgreSQL备份pg_转储无法与windows任务计划程序一起使用,windows,postgresql,powershell,scheduled-tasks,Windows,Postgresql,Powershell,Scheduled Tasks,我有一个powershell脚本,它执行以下操作: 停止服务 打开本地目录 对PostgreSQL数据库执行pg_转储 启动服务 在powershell中以本地用户身份运行此功能非常有效 但是,通过windows任务调度器进行调度时,它会执行除(3)转储PostgreSQL数据库之外的所有步骤。 有什么想法吗?我不明白为什么在运行powershell时它能工作,但运行计划任务却不能。 其他资料: 本例中的本地用户是具有管理员权限的域用户。任务计划程序设置为以具有最高权限的域用户身份运行 pgp

我有一个powershell脚本,它执行以下操作:

  • 停止服务
  • 打开本地目录
  • 对PostgreSQL数据库执行pg_转储
  • 启动服务
  • 在powershell中以本地用户身份运行此功能非常有效

    但是,通过windows任务调度器进行调度时,它会执行除(3)转储PostgreSQL数据库之外的所有步骤。

    有什么想法吗?我不明白为什么在运行powershell时它能工作,但运行计划任务却不能。

    其他资料:

    • 本例中的本地用户是具有管理员权限的域用户。任务计划程序设置为以具有最高权限的域用户身份运行
    • pgpass文件存在于正确的AppData位置

    感谢您的帮助

    pg_dump
    调用的输出(stdout和stderr)重定向到文件中,以便您可以看到错误消息。这很可能是一个权限问题,但如果没有错误消息,您将无法准确判断权限。@a_horse_使用
    | Out File C:\path
    将一个文件添加到
    pg_dump
    语句中时,该文件中没有任何内容。这是因为我只路由stdout而不是stderr吗?我不知道Powershell,但很可能是的。在批处理文件中,stderr是使用
    2>输出重定向的。err
    @a_horse_和_no_name这是问题所在,错误是
    pg_dump:pg_dump:[archiver(db)]到数据库“datab”的连接失败:fe_sendauth:没有提供密码
    ,当它被定义在正确的AppData位置时,我不太理解,脚本在调度程序之外工作……这意味着
    pgpass.conf
    不是它应该在的位置(
    %APPDATA%\postgresql\pgpass.conf
    ),或者其中的信息不正确。