Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog. You can find information on programming, linux, documentation, tips for code and database optimization, my thoughts and rants, and whatever else I feel like sharing. Feel free to contribute to the blog by posting comments and asking questions.
Linux

easy mysql backup

Here’s an example of quick script I wrote in PHP and added as a cronjob to backup some mysql databases:

// dump database tables to sql text files //
exec('mysqldump -uroot -pPasswordHere music > /tmp/music.sql');
exec('mysqldump -uroot -pPasswordHere taskfreak > /tmp/taskfreak.sql');
// pack into tarballs //
exec("tar -cf /tmp/music.sql.tar /tmp/music.sql");
exec("tar -cf /tmp/taskfreak.sql.tar /tmp/taskfreak.sql");
// gzip tarballs //
exec("gzip /tmp/music.sql.tar");
exec("gzip /tmp/taskfreak.sql.tar");

Related posts:

  1. a backup system – for the poor and lazy
  2. linux random tar stuff
  3. php/linux – performing an http post the easy way
  4. CronJobs – Creating CronJobs with Crontab in Linux

Leave a Reply