Discuss phpwcms here, please do not post support requests, bug reports, or feature requests! Non-phpwcms questions, discussion goes in General Chat!
update
Moderator
Posts: 6455 Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor
Post
by update » Wed 5. Apr 2006, 12:54
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
rushclub
Posts: 915 Joined: Tue 17. Feb 2004, 18:52
Post
by rushclub » Wed 5. Apr 2006, 13:15
can you tell us, what script it is?
rush
3 (!) Jahre warten reichen mir. Ich bin erst mal weg.
update
Moderator
Posts: 6455 Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor
Post
by update » Wed 5. Apr 2006, 17:24
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
update
Moderator
Posts: 6455 Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor
Post
by update » Fri 7. Apr 2006, 10:04
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?
Pappnase
Post
by Pappnase » Sat 8. Apr 2006, 04:58
hello
will be added in the next days
update
Moderator
Posts: 6455 Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor
Post
by update » Sat 8. Apr 2006, 12:02
Hi
claus
Pappnase
Post
by Pappnase » Mon 10. Apr 2006, 04:52
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