Linux下PostgreSQL数据库备份(pg_dump 等)脚本如何写啊?
我想实现在客户端的页面上点个按钮什么的,来执行下面这个位于Linux服务器上的脚本。下面这个是我大概写的,可是不知什么原因无法执行啊。望高人指点一下。
注:这个脚本在windows服务器下可以正常运行。cd /usr/lib/postgresql/8.4/bin
pg_dump -D -h localhost -U postgres commonsns>/home/hbhl/db_%date:~0,4%%date:~5,2%%date:~8,2%.txt另注:项目是放在>/home/hbhl这个用户目录"hbhl"下的。

解决方案 »

  1.   

    先自己顶下。
    “/usr/lib/postgresql/8.4/bin”这个是数据库相关工具程序的目录。
      

  2.   

    cd /usr/lib/postgresql/8.4/bin
    pg_dump -D -h localhost -U postgres commonsns>/home/hbhl/db`date +%Y%m%d`.txt
      

  3.   

    在linux下时间不是那样搞的datestr=$(date +%Y%m%d)
    /usr/lib/postgresql/8.4/bin/pg_dump -D -h localhost -U postgres commonsns>/home/hbhl/db_${datestr}.txt
      

  4.   

    我是说Linux系统用户的权限啊
      

  5.   

    加入我把上面的代码存成(Shell的)test.sh文件,在执行“./test.sh”后,报错“-bash: ./test.sh: Permission denied
    ”这个错。要如何解决啊?
      

  6.   

    执行权限没设置
    chmod +x test.sh -- 设为所有人都可执行
    或改为只有本用户、本组可执行,请参看man chmod