diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 74037147760ceb996dad2ffd0adbe4667852818e..9d5317fdd88efb5ee6bf9366d39e13c0f02d5192 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -366,9 +366,11 @@ print $langs->trans("BackupDescY").'<br><br>'; id="filename_template" value="<?php $prefix='dump'; -if ($label == 'MySQL') $prefix='mysqldump'; -if ($label == 'PostgreSQL') $prefix='pg_dump'; -$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.sql'; +$ext='.sql'; +if ($label == 'MySQL') { $prefix='mysqldump'; $ext='sql'; } +//if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; } +if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='sql'; } +$file=$prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext; echo $file; ?>" /> <br> <br> @@ -376,16 +378,19 @@ echo $file; <?php // Define compressions array -$compression=array( - 'none' => array('function' => '', 'id' => 'radio_compression_none', 'label' => $langs->trans("None")), - 'gz' => array('function' => 'gzopen', 'id' => 'radio_compression_gzip', 'label' => $langs->trans("Gzip")), -); +$compression=array(); if ($label == 'MySQL') { -// $compression['zip']= array('function' => 'dol_compress', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip")); // Not open source format. Must implement dol_compress function + $compression['none'] = array('function' => '', 'id' => 'radio_compression_none', 'label' => $langs->trans("None")); + $compression['gz'] = array('function' => 'gzopen', 'id' => 'radio_compression_gzip', 'label' => $langs->trans("Gzip")); + // $compression['zip']= array('function' => 'dol_compress', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip")); // Not open source format. Must implement dol_compress function $compression['bz'] = array('function' => 'bzopen', 'id' => 'radio_compression_bzip', 'label' => $langs->trans("Bzip2")); } - +else +{ + $compression['none'] = array('function' => '', 'id' => 'radio_compression_none', 'label' => $langs->trans("Default")); + $compression['gz'] = array('function' => 'gzopen', 'id' => 'radio_compression_gzip', 'label' => $langs->trans("Gzip")); +} // Show compression choices print '<div class="formelementrow">'; diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index d66df365afa508f4d1352a527413b2e7fd43eb09..0cd1ae19fa9496ac657660da6f05763bdb06b4da 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -94,7 +94,7 @@ print $langs->trans("RestoreDesc3",DOL_DATA_ROOT).'<br><br>'; ?> <div class="formelementrow"> <input type="radio" name="what" value="mysql" id="radio_dump_postgresql"<?php echo ($radio_dump=='postgresql_options'?' checked':''); ?> /> - <label for="radio_dump_postgresql">PostgreSQL Restore (pg_restore)</label> + <label for="radio_dump_postgresql">PostgreSQL Restore (pg_restore or psql)</label> </div> <?php } @@ -170,6 +170,9 @@ else if ($label == 'PostgreSQL') }*/ $paramcrypted.=" -W"; $paramclear.=" -W"; + // With psql: + $paramcrypted.=" -f"; + $paramclear.=" -f"; echo $langs->trans("ImportPostgreSqlDesc"); print '<br>'; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 57fbb045a02cdb410f0ab91b9c884fe5d93d8807..203776bc7f9db9e3c0b6f4d40307b9cfc8361f4b 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * * This program is free software; you can redistribute it and/or modify @@ -289,7 +289,9 @@ if ($what == 'postgresql') if (preg_match("/\s/",$command)) $command=$command=escapeshellarg($command); // Use quotes on command //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass); - $param=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host; + //$param="-F c"; + $param="-F p"; + $param.=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host; $param.=" -U ".$dolibarr_main_db_user; if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port; if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param.=" --disable-dollar-quoting"; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 6593b2d896bb2188032d6f7d5f9a7a594e3e741a..25263deee46437ebaaec5af9ec8c3c95a35d561a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1209,11 +1209,14 @@ class DoliDBPgsql extends DoliDB */ function getPathOfRestore() { - $fullpathofdump='/pathtopgrestore/pg_restore'; + //$tool='pg_restore'; + $tool='psql'; - if (file_exists('/usr/bin/pg_restore')) + $fullpathofdump='/pathtopgrestore/'.$tool; + + if (file_exists('/usr/bin/'.$tool)) { - $fullpathofdump='/usr/bin/pg_restore'; + $fullpathofdump='/usr/bin/'.$tool; } else { @@ -1223,7 +1226,7 @@ class DoliDBPgsql extends DoliDB { $liste=$this->fetch_array($resql); $basedir=$liste['data_directory']; - $fullpathofdump=preg_replace('/data$/','bin',$basedir).'/pg_restore'; + $fullpathofdump=preg_replace('/data$/','bin',$basedir).'/'.$tool; } }