NYCPHP Meetup

NYPHP.org

[nycphp-talk] Scripting to get a backup of yourcurrent MySQL database.

Ben Sgro (ProjectSkyLine) ben at projectskyline.com
Wed Oct 3 16:42:07 EDT 2007


Hello,

I just came into this conversation mid way, but I wanted to include a script 
I use
via cron to do mysql backups. Not sure if someone already provided this.

[sk at tinman ~]$ crontab -l
0 */23 * * * /path/to/sql_backup.sh

[sk at tinman ~]$ cat sql_backup.sh
DATE=`date '+%m%d%Y'`
DUMPFILE="/path/to/all_databases-$DATE.sql.gz"
/usr/bin/mysqldump --all-databases --user=root --password=changeme | gzip > 
$\
DUMPFILE

- Ben
----- Original Message ----- 
From: "Anthony Wlodarski" <aw at sap8.com>
To: "'NYPHP Talk'" <talk at lists.nyphp.org>
Sent: Wednesday, October 03, 2007 4:13 PM
Subject: RE: [nycphp-talk] Scripting to get a backup of yourcurrent MySQL 
database.


>I assume a ten minute window as I have not done it before.  I am going to
> have Cron call that script but just to make sure at the start of the 
> script
> I am going to make sure people don't have access to the CMS so the 
> database
> doesn't try to update itself.  I found that link useful, actually found it
> before I posted on the user group.
>
> Anthony Wlodarski
> Senior Technical Recruiter
> Shulman Fleming & Partners
> 646-285-0500 x230
> aw at sap8.com
>
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] 
> On
> Behalf Of Rob Marscher
> Sent: Wednesday, October 03, 2007 2:43 PM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] Scripting to get a backup of your current MySQL
> database.
>
> On Oct 3, 2007, at 12:16 PM, Anthony Wlodarski wrote:
>> I think for sake of ease of doing this project we will just have a ten
>> minute drop on the server at midnight every night to backup the
>> database.
> I doubt it will take 10 minutes.  From http://dev.mysql.com/doc/
> refman/5.0/en/backup.html:
>
> "You can also create a binary backup simply by copying all table
> files (*.frm, *.MYD, and *.MYI  files), as long as the server isn't
> updating anything. The mysqlhotcopy script uses this method. (But
> note that these methods do not work if your database contains InnoDB
> tables. InnoDB does not store table contents in database directories,
> and mysqlhotcopy  works only for MyISAM tables.)"
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php 




More information about the talk mailing list