Welcome Guest, Not a member yet? Register   Sign In
MySQL Backup Script in CI
#1

[eluser]deanpcmad[/eluser]
Hi,

I'm new to CI and was wondering if I could make a MySQL backup script that can backup multiple databases.
Any help appreciated.

Thanks!
#2

[eluser]jedd[/eluser]
Hi Dean, and welcome to the forums.

Are you set on doing this in CI (and if so, why?).

I'd recommend you look at doing this kind of thing outside - say a cron job and some CMD or bash scripts to do hotbackups, or take the DB offline and do a dump (preferred - much faster).
#3

[eluser]deanpcmad[/eluser]
"take the DB offline and do a dump (preferred - much faster)."
How would I do that? Is there a guide on how to?
#4

[eluser]deanpcmad[/eluser]
I'm looking to make a PHP script that I can run as a CRON
#5

[eluser]jedd[/eluser]
[quote author="deanpcmad" date="1237245091"]"take the DB offline and do a dump (preferred - much faster)."
How would I do that? Is there a guide on how to?[/quote]

Depends on your system.

On mine (a real OS) I run this kind of script from cron:

Code:
/etc/init.d/mysql stop
tar cfz /var/local/backups/mysql-$date.tgz  /var/lib/mysql
/etc/init.d/mysql start

I have a snippet somewhere to give me $date in a format I like (ISO8601).

If you can't take your DB offline for backing up then there are other MySQL utilities for pulling data out of a live system, but if you've got that kind of requirement you probably wouldn't be asking how to do such a thing on a CI forum.

Oh .. and you really do not want to do backups, via cron, written in PHP, of your database. Trust me.




Theme © iAndrew 2016 - Forum software by © MyBB