You are here: Home Database PostgreSQL Basics make dumps and backups with php
Search
Advanced Search…
E-Mail

Webmail: webmail.wyden.com

E-Mail Preferences: postfix.wyden.com/users

E-Mail Administration: postfix.wyden.com

Statistics
Total: 473
Total Pages: 286
Total Folders: 87
Total Files: 18
Total Links: 26
Last modification: 19.04.2012 15:21
 

make dumps and backups with php

by Wyden Silvan last modified 05.03.2011 11:10

<?php

$dump_file  = 'dump.sql';
$db_user    = 'openerp';
$db_pass    = 'MYPASSWORD';
$db_dbname  = 'reservation2';
$db_host    = 'localhost';

putenv('PGPASSWORD=' . $db_pass);
putenv('PGUSER=' . $db_user);
putenv('PGHOST=' . $db_host);

//make backup of a database with pg_dump
//system('pg_dump '.$db_dbname.' > '.$dump_file);

//create new databse $db_dbname
system('createdb ' . $db_dbname);

//copy template into new databse
system('psql -f openerp_template.sql -d ' . $db_dbname);

?>
~