I presently use the following to export the database and as per my
earleir post hope to have an equivent to do the backup as per:
a) check for time since the last backup
b) if older than <x> hrs
(i) perform a vacuum analyze
(ii) force a call to dbbackup
(iii) add a new record into fsyslog
thanks
R
CREATE OR REPLACE FUNCTION export_database(text)
RETURNS text AS
'
declare
tblname record;
cnt record;
dirchar varchar := ''/''; --char(92); --''/''; -- directory separator
character, char 92 is backslash or / for windows
tname varchar :='''';
tquery varchar :='''';
filename varchar :='''';
begin
if $1 <> '''' then
tname := dirchar||$1||dirchar;
else
tname := dirchar;
end if;
for tblname in select tablename from pg_tables WHERE not(tablename like
''pg_%'') and not(tablename like ''t_%'')
and not(tablename like ''%_list'') order by tablename loop
filename := tname|| lower(tblname.tablename)||''.dat'';
tquery := ''copy '' || tblname.tablename || '' to '' ||
quote_literal(filename)||'' with binary '';
execute tquery;
end loop;
return tquery;
end;