Search Postgresql Archives

Automating Backup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux