|
PCCS MySQLDatabase Admin Tool version 1.3.4
|
/ -> mysqldb_create_backupscript.php
1 <?php
2 /************************************************************************
3 PCCS MySQLDatabase Admin Tool
4 Copyright (C) Chauncey Thorn
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA , USA.
19 **************************************************************************/
20
21 /////////////////////////////////////////////////////////////////////////////// 22 // Create backup script 23 // no need to modify unless you like hacking 24 // bugs report to cthorn 25 /////////////////////////////////////////////////////////////////////////////// 26 $backup_filename="backup.php";
27
28 $fb = fopen($appfiledir . $backup_filename,"w");
29 fputs($fb,"<?php\n//** Generated by PCCS-MyAppGen $today\n");
30 fputs($fb,"/////////////////////////////////////////////////////////////////////////////////////\n");
31 fputs($fb,"// coder: cthorn\n");
32 fputs($fb,"////////////////////////////////////////////////////////////////////////////\n");
33 fputs($fb,"//\n");
34 fputs($fb,"//\n");
35 fputs($fb,"if (\$argv[0] ==\"\"):\n");
36 fputs($fb," print \"<CENTER>\";\n");
37 fputs($fb," print \"This Page allows you to make a backup of your database App\";\n");
38 fputs($fb," print \"<br>\";\n");
39 fputs($fb," print \"<A HREF=$backup_filename?action=backup>BACKUP APPLICATION</A>\";\n");
40 fputs($fb," print \"</CENTER>\";\n");
41 fputs($fb," \n");
42 fputs($fb,"\n");
43 fputs($fb,"endif;\n");
44
45
46 fputs($fb,"\$dbname = \"$webdatabase\"; //your Application Database Name\n");
47
48 fputs($fb,"\$_time = date(\"His\");\n");
49 fputs($fb,"\$_date = date(\"Ymd\");\n");
50 fputs($fb,"\$dump_filename = \"\$_date\$_time_\$dbname.sql\";\n");
51 fputs($fb,"\$_admtool = \"/usr/local/bin/mysqldump\";\n");
52 fputs($fb,"\$_gzip = \"/bin/tar\";\n");
53 fputs($fb,"\$dump_filename = \"\$_date\$_time_\$dbname.sql\";\n");
54 fputs($fb,"//\n");
55 fputs($fb,"// Below are the paramaters for mysqldump\n");
56 fputs($fb,"\$par1 = '--opt';\n");
57 fputs($fb,"\$par2 = '-uroot';\n");
58 fputs($fb,"\$db_dump = \"\$_admtool \$par1 \$par2 \$dbname > ./\$dump_filename\";\n");
59 fputs($fb,"\$gz_dump = \"\$_gzip -czf ./\$dump_filename.tar.gz ./\$dump_filename\";\n");
60 fputs($fb,"\n");
61 fputs($fb,"if (\$action == \"backup\"):\n");
62 fputs($fb,"\t\theader(\"Content-type: application/gzip\");\n");
63 fputs($fb,"\t\theader(\"Content-Disposition: attachment; filename=\$dump_filename.tar.gz\");\n");
64 fputs($fb,"\n");
65
66 fputs($fb,"\t\texec(\"\$db_dump\");\n");
67 fputs($fb,"\t\texec(\"\$gz_dump\");\n");
68
69 fputs($fb,"\t\treadfile(\"\$dump_filename.tar.gz\");\n");
70 fputs($fb,"\t\tunlink(\"\$dump_filename.tar.gz\");\n");
71 fputs($fb,"endif;\n");
72 fputs($fb,"\n");
73
74 fputs($fb,"//\n");
75 fputs($fb,"//////////////////////////////////////////////////////////////////////////\n");
76 fputs($fb,"?>\n");
77 fclose($fb);
78
79 ?>
| |