PCCS MySQLDatabase Admin Tool version 1.3.4


/ -> mysqldb_backup.php

1  <?php
2  ////////////////////////////////////////////////////////////////////////////
3  // Coded by: Chauncey Thorn
4  // email: cthorn
5  /************************************************************************
6  PCCS MySQLDatabase Admin Tool
7  Copyright (C) Chauncey Thorn
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 2
12  of the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA , USA.
22  **************************************************************************/
23  // updated 10-23-2000
24  // -- moving to a single file for global include files
25  // only need dbconnect for this script...
26  // require('mysqldb_app_includes.php');
27   
28  require('incs/dbconnect.php');
29 
30  $_time = date("His");
31  $_date = date("Ymd");
32  $dump_filename = "$_date$_time_$dbname.sql";
33  $_admtool = "/usr/local/bin/mysqldump";
34  $_gzip = "/bin/tar";
35  $dump_filename = "$_date$_time_$dbname.sql";
36  //
37  // Below are the paramaters for mysqldump
38  $par1 = '--opt';
39  if(!$db_passed) {
40  $par2 = "-u".$db_user;
41  } else {
42  $par2 = "-u".$db_user." -p".$db_passwd;
43  }
44 
45  $db_dump = "$_admtool $par1 $par2 $dbname > ./tmp/$dump_filename";
46  $gz_dump = "$_gzip -czf $dump_filename.tar.gz ./tmp/$dump_filename";
47 
48  if ($action == "backup"):
49          header("Content-type: application/gzip");
50          header("Content-Disposition: attachment; filename=$dump_filename.tar.gz");
51 
52 
53          exec ("$db_dump");
54          exec ("$gz_dump");
55 
56          readfile("./tmp/$dump_filename.tar.gz");
57          unlink("./tmp/$dump_filename.tar.gz");
58          // log_this("BACKUP CREATED for $dbname","dblog.txt");
59 
60  endif;
61 
62  ?>


Generated: Sat Jan 27 15:40:36 2001 Generated by PHPXref 0.1.2
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002