backups

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

backups

Post by elecktricity »

whats the easiest way to make backups of big databases with php? I tried a few ideas but they didnt seem to work well they kept timing out ect? I dont want to install anything just something I can create with php or something else simple.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Using the results from SHOW DATABASES and SHOW TABLES, one can build a tree of how the tables are oriented. You can then use SHOW CREATE TABLE against these names to create the structure queries. Now you have to be careful of the tables using InnoDB as a storage engine as they could easily be dependent on another table existing first. ... Granted there are a few syntax ways around that.

After you export the structure, you can begin dumping the individual tables' data. I'd count the number of queries performed and try to chop them at a certain length and move to another file.
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Post by elecktricity »

i tried something like your approact, it kept timing out or giving me an error saying its used to much memory on it...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm guessing you kept the whole thing in memory until you finished a file? I was suggesting outputting as you go.

You may need to call set_time_limit() with a large value, or zero, depending on needs.
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Post by elecktricity »

it hasnt given me a time limit error, its a memory error...
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could call mysqldump with exec().
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Does it have to be done with PHP? If so, can you tap into phpMyAdmin for how they do it?
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

Post by elecktricity »

no it really dosnt have to be done in php but im more famaliar with it so I thought it would be easier, but if you have any other ideas shoot ^^
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

elecktricity wrote:no it really dosnt have to be done in php but im more famaliar with it so I thought it would be easier, but if you have any other ideas shoot ^^
then why not use the mysqldump instead of php. I don't think that will cause memory errors, timouts or whatsoever.
Post Reply