Page 1 of 1
Backing up my db in an easy way
Posted: Wed 5. Apr 2006, 12:54
by update
Hi,
yesterday I came across a little nice script to make a backup of the phpwcms db, just by calling it from my web browser (one click)
It stores the sql file at the server and additionally sends it automatically to my email address. Just tested it and it works!
Greetings
claus
Posted: Wed 5. Apr 2006, 13:15
by rushclub
can you tell us, what script it is?
rush
Posted: Wed 5. Apr 2006, 17:24
by update
Hi rushclub
it looks like this:
Code: Select all
<?php
$username = 'xxxxxxx';#db user name
$passwort = 'xxxxxxx';#password for database
$db_name = 'xxxxxxxxxxx';#Name of database
$filename = date(d.'.'.m.'.'.Y);
$mail = 'youremailname@youremaildomain.tld';#your emaiaddress
$Subject = "Backup of Database $db_name at $filename";
system('/usr/bin/mysqldump -u'.$username.' -p'.$passwort.' -h localhost '.$db_name.' | /bin/gzip > '.$filename.'.sql.gz', $fp);
//saves your db.sql, stores it in your web root and sends it as attachment
// to your specified email address (I don't know if someone has to change
// the path to mysqldump too?)
if ($fp==0) echo ''; else echo 'ERROR!!! Es ist ein Fehler aufgetreten';
$filename_n = $filename.'.sql.gz';
$Header = "From: Backup System <$mail>";
$Trenner = md5(uniqid(time()));
$Header .= "\n";
$Header .= "MIME-Version: 1.0";
$Header .= "\n";
$Header .= "Content-Type: multipart/mixed; boundary=$Trenner";
$Header .= "\n\n";
$Header .= "This is a multi-part message in MIME format";
$Header .= "\n";
$Header .= "--$Trenner";
$Header .= "\n";
$Header .= "Content-Type: text/plain";
$Header .= "\n";
$Header .= "Content-Transfer-Encoding: 8bit";
$Header .= "\n\n";
$Header .= "Backup der Datenbank $db_name vom $filename";
$Header .= "\n";
$Header .= "--$Trenner";
$Header .= "\n";
$Header .= "Content-Type: application/x-gzip; name=$filename_n";
$Header .= "\n";
$Header .= "Content-Transfer-Encoding: base64";
$Header .= "\n";
$Header .= "Content-Disposition: attachment; filename=$filename_n";
$Header .= "\n\n";
$Dateiinhalt .= fread(fopen($filename_n, "r"), filesize($filename_n));
$Header .= chunk_split(base64_encode($Dateiinhalt));
$Header .= "\n";
$Header .= "--$Trenner--";
mail($mail, $Subject, "", $Header);
?>
Greetings
claus
Posted: Fri 7. Apr 2006, 04:57
by Pappnase
hello
how about to use
http://www.mysqldumper.de/de/index.php
it's an good tool! and when you're able to work with cronjobs you're able to run it automatic

Posted: Fri 7. Apr 2006, 10:04
by update
Ah
I just took a seat to tell the world that I've found mysqldumper - - -
as far as I got it this tool is able to shift all the saved stuff back into a new (old) database too, right? I will check it out - sounds really promising
Greetings
claus
Edit: Perhaps some topic for Q&A?
Posted: Sat 8. Apr 2006, 04:58
by Pappnase
hello
will be added in the next days

Posted: Sat 8. Apr 2006, 12:02
by update
Hi
claus
Posted: Mon 10. Apr 2006, 04:52
by Pappnase
claus wrote:Ah
I just took a seat to tell the world that I've found mysqldumper - - -
as far as I got it this tool is able to shift all the saved stuff back into a new (old) database too, right? I will check it out - sounds really promising
Greetings
claus
Edit: Perhaps some topic for Q&A?
Added
german ->
http://faq.phpwcms-docu.de/5_67_de.html
english ->
http://faq.phpwcms-docu.de/3_67_en.html