MySQL Backup

What is the best way to backup a MySQL database aside from what the seb
server does on its own?

Is there an effective way to write a php script that does this
periodically, maybe saves the database (in an SQL file??) somewhere
either on the web server or for downloading?

--Kenoli
kenoli [ Sa, 13 Januar 2007 17:44 ] [ ID #1594341 ]

Re: MySQL Backup

kenoli wrote:
> What is the best way to backup a MySQL database aside from what the seb
> server does on its own?
>
> Is there an effective way to write a php script that does this
> periodically, maybe saves the database (in an SQL file??) somewhere
> either on the web server or for downloading?

doing this periodically you need to have access to cron jobs, if you have
access to cron jobs, then you most likely have access to mysqldump whcih you
can use to make backups with, just direct the output to a place where you can
download the file from.

--

//Aho
Shion [ Sa, 13 Januar 2007 17:53 ] [ ID #1594342 ]

Re: MySQL Backup

In article <1168706666.210414.228160 [at] 38g2000cwa.googlegroups.com>,
kenoli <kenoli [at] igc.org> wrote:

> What is the best way to backup a MySQL database aside from what the seb
> server does on its own?
>
> Is there an effective way to write a php script that does this
> periodically, maybe saves the database (in an SQL file??) somewhere
> either on the web server or for downloading?

<?php
/**
* You most likely do not have to reinvent the wheel here Kenoli.
* the url below doesn't cut it for you, you can always take a
* peek at the source code....
* [at] author Koncept
* [at] link http://sourceforge.net/projects/phpmybackup
* [at] return string "Stop. Hammertime."
*/
?>

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Koncept [ So, 14 Januar 2007 06:20 ] [ ID #1594970 ]

Re: MySQL Backup

kenoli wrote:
> What is the best way to backup a MySQL database aside from what the seb
> server does on its own?
>
> Is there an effective way to write a php script that does this
> periodically, maybe saves the database (in an SQL file??) somewhere
> either on the web server or for downloading?
>
> --Kenoli

Backing up a database is arguably a command-line or OS-level function.
It's relatively trivial to write a bash or Perl script (under 10 lines
or so, and a good learning exercise) that does this:

1) Determine the current date/time.
2) Execute a "mysqldump" and aim its contents into a file called
something like {dbname}_timestamp.sql
3) tar/gzip it.

Then you can add this to your crontab, or just run it manually on an
occasional basis.

I've done this, and more (including php.ini, my.cnf, all http confs, all
log files, all web servable directories, etc.) to basically backup an
entire LAMP environment for relatively easy restore -- with a single
command.

The basics are very easy, and I'd strongly suggest trying it out
yourself -- you'll quickly find ways to expand it (and easily). Mine is
under 50 lines of code or so.
Paul Bramscher [ Mi, 17 Januar 2007 18:39 ] [ ID #1598897 ]

Re: MySQL Backup

Thanks to Paul and Koncept --

Koncept: The script you refer to looks good. I'll get into it.

Paul: The fact that writing something in BASH script or Perl would be
starting from scratch in those languages makes it a bit of a challenge
to think about taking it on, though it sounds elegantly simple.

Thanks,

--Kenoli

Paul Bramscher wrote:
> kenoli wrote:
> > What is the best way to backup a MySQL database aside from what the seb
> > server does on its own?
> >
> > Is there an effective way to write a php script that does this
> > periodically, maybe saves the database (in an SQL file??) somewhere
> > either on the web server or for downloading?
> >
> > --Kenoli
>
> Backing up a database is arguably a command-line or OS-level function.
> It's relatively trivial to write a bash or Perl script (under 10 lines
> or so, and a good learning exercise) that does this:
>
> 1) Determine the current date/time.
> 2) Execute a "mysqldump" and aim its contents into a file called
> something like {dbname}_timestamp.sql
> 3) tar/gzip it.
>
> Then you can add this to your crontab, or just run it manually on an
> occasional basis.
>
> I've done this, and more (including php.ini, my.cnf, all http confs, all
> log files, all web servable directories, etc.) to basically backup an
> entire LAMP environment for relatively easy restore -- with a single
> command.
>
> The basics are very easy, and I'd strongly suggest trying it out
> yourself -- you'll quickly find ways to expand it (and easily). Mine is
> under 50 lines of code or so.
kenoli [ Mi, 17 Januar 2007 20:46 ] [ ID #1598907 ]
PHP » alt.php » MySQL Backup

Vorheriges Thema: mail function error
Nächstes Thema: Merging two sql databases