Fix: Option to make pg_dump/restore
This commit is contained in:
parent
900cdd5368
commit
12ae552486
@ -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">';
|
||||
|
||||
@ -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>';
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user