Error in function to pg_dump: Standard in must be a tty - Mailing list pgsql-general

From Siew Hui, Wong
Subject Error in function to pg_dump: Standard in must be a tty
Date
Msg-id 002901c41de2$d762d750$3c0a0a0a@siewhui
Whole thread Raw
In response to Re: pg_ctl problem  (jseymour@LinxNet.com (Jim Seymour))
List pgsql-general
Postgresql 7.3.4
RH 8.0

Hello all,

The client requirements are that from the website(a coldfusionmx app), they
could backup and restore the database from the list of backups available.
All i've given to work on is just that to allow user to select backup to
restore and also to allow user to perform a manual database backup.

Here's how the "manual backup" process goes. When user clicks on "Backup
Database Now", a row is inserted to a table (app_dbactionb) to trigger off
the pg_dump. Problem is an error msg appeared when i insert test data into
table:

"standard in must be a tty."

Below are the functions and trigger concerned:
###################################
CREATE TRIGGER autobackup
    AFTER INSERT ON app_dbactionb
    FOR EACH ROW
    EXECUTE PROCEDURE initbackup ();


CREATE FUNCTION initbackup () RETURNS "trigger" AS '
 begin
  perform Backup ();
  return NEW;
 end;
' LANGUAGE 'plpgsql';


CREATE FUNCTION backup () RETURNS integer
    AS '
  system("/home/postgres/testbackupdb");
  return 0;
'LANGUAGE plperlu;
###################################

Below is the testbackupdb (chmod 777, owner postgres):

#!/bin/bash
#File is named according to abbreviation of week name (Sun...Sat)
#e.g. nsvm_Mon_2004.db

backupdate=`date +%a_%Y`
/bin/su - postgres -c "/usr/local/pgsql/bin/pg_dump -f
/home/postgres/nsvm_$backupdate.db nsvm"
echo "Backup at `date` :
nsvm_$backupdate.db">>/home/postgres/nsvm_backup_log


I really appreciate any form of advice and feedback on this error. Please
let me know too, if there are more efficient ways to allow user to backup
from a webpage :) Thank you all for the time.


Best regards,
siew hui





pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: ERROR: invalid memory alloc request size 0
Next
From: Tom Lane
Date:
Subject: Re: Orphaned trigger -- bug?