Re: PHP DATABASE BACKUP SYSTEM

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

 



<?php

include ('db_constants.php');       // File should include at three lines which set
                                    // database name, username, and password.
                                    // $db_name, $db_username, $db_password
                                    // The file should be secured 400 (owner=read, group=none, 
other=none)

                                    // Note that INSIDE of MySQL you need to grant FULL
                                    // access to the user which is performing the
                                    // backups - see the MySQL reference manual 'GRANT' command

$fil_name = '/tmp/'.$db_name.'-'.date('Y_md_his');

$bak_file = $fil_name.'.sql';       // Backup File
$err_file = $fil_name.'.err';       // File where errors are written

$isok = system ("mysqldump --user ".$db_username.' --password='.$db_password.' 
'.$db_name.' > '.$back_file.' 2> '.$err_file);

if ( ! $isok )
{
   echo "Something appears to have gone wrong, check the error file \n";
   echo "    ".$err_file."\n";
   echo "for error messages.\n";
}

?>




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux