Does anyone know how to do this in PHP or of a premade (and free) script out
there, preferably written in PHP?
Thanks,
Mosher
Dump it using mysqldump into a text file using one of the system() or
exec() type function calls, then either attach the resulting text file
to your email or make it the body of the message.
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
.... though if your data is really important, perhaps regular e-mail should
be avoided, lest anyone snoop in on it...
I'm no great Php expert, probably not perfect Php, but here's the
function I use in my script:
////////////////////////////////////////////
function create_db_backup ($path, $tables = "")
{
$filename=$DBNAME . "_backup" . "_" . date("n-j-y_H-i-s") .
".sql";
system("mysqldump --add-drop-table -u $USRNAME -p $PASSWRD $DBNAME
$tables > $path/$filename", $result);
system ("gzip $path/$filename", $result);
$gzname = $filename . ".gz";
return $gzname;
}
$path is the directory I save backups to.
$tables is optional. If empty, mysqldump will backup all tables,
otherwise it's a list of tables to backup (separated by a space, e.g."
table1 table2 table3" - no quotes).
I use --add-drop-table because it seems like the simplest sql file to
use for a restore.
Finally, I gzip it to make it smaller.
Now all you have to do is mail it to yourself. I use Phpmailer.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Especially if it contains sensitive data. If you have ssh or sftp access
to the server you can always download the dump file via sftp which
makes it much safer. I manage my own servers and all the databases are
dumped to text files on a daily basis and rsync'd to my local machine
on a daily basis via ssh.
Mosher
"Chuck Anderson" <website...@seemy.sig> wrote in message
news:xtCdncHaEu3...@comcast.com...