Subject Re: [firebird-php] good news everyone : Firebird driver will be back in php 5.3.4
Author Umberto Masotti
On 03/11/2010 16:58, Sándor Tamás wrote:
> May I have a small voice of question: will it be possible to backup
> through PHP?
> Because with the 5.2 extension, it always giving errors, or more, it
> doesn't do anything.

I do daily backup of a db set using this script excerpt.
It works for me on Ubuntu server, PHP 5.2.
$databases is an array of db aliases
********

$fbk_gz = "/tmp/mail_fbk.tgz";
$tar_parms = "-zcvf";
$cmd_tar = "tar $tar_parms $fbk_gz ";



function db_backup ( $srvc, $db, $periodo )
{
$dest = "/tmp/$db$periodo.fbk";
if ( file_exists ( $dest)) {
$aa = unlink ( $dest );
echo"
-- Deleting previous $dest: $aa";
}
ibase_backup($srvc, $db, $dest );
echo "
-- Waiting 5 seconds to terminate backup..."; sleep(5); echo "DONE!";
return $dest;
}

$fatti = array();
$service = ibase_service_attach('localhost', FB_USERNAME, FB_PASSWORD);
$resto = calcolo_nome(); // to compute filename for periodic backup
foreach ( $databases as $db )
$fatti[] = db_backup ($service, $db, $resto);
ibase_service_detach($service);

$lista = implode ( ' ', $fatti );

echo "
-- Waiting 10 seconds more..."; sleep(10); echo "DONE!";

// making a compressed file from all backups

if ( file_exists ( $fbk_gz)) {
$aa = unlink ( $fbk_gz );
echo"
-- Deleting previous periodic backup $fbk_gz: $aa";
}

echo "
-- expected tar command:
$cmd_tar $lista
-- executed tar:
";
echo exec ("$cmd_tar $lista");
echo "
-- End compression";
********
This script is executed every night.
Waiting was added becausa because ibase_backup() returns immediatly and
not at end of backup.


Ciao.
Mimmo.