From babe924921d06c255a9655c7a70bee1711db6381 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 8 Dec 2007 18:44:52 +0000 Subject: [PATCH] database dump part 1 git-svn-id: file:///home/shish/svn/shimmie2/trunk@646 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/svn_update/main.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/contrib/svn_update/main.php b/contrib/svn_update/main.php index 027d9627..d4bb7f52 100644 --- a/contrib/svn_update/main.php +++ b/contrib/svn_update/main.php @@ -23,6 +23,9 @@ class SVNUpdate extends Extension { if($event->get_arg(0) == "update") { $this->theme->display_update_log($event->page, $this->run_update()); } + if($event->get_arg(0) == "dump") { + $this->theme->display_update_log($event->page, $this->run_dump()); + } //if($event->get_arg(0) == "switch") { // $this->theme->display_update_log($event->page, $this->run_update()); //} @@ -41,6 +44,21 @@ class SVNUpdate extends Extension { private function run_update() { return shell_exec("svn update"); } + private function run_dump() { + global $database_dsn; + $matches = array(); + + // FIXME: MySQL specific + if(preg_match("#^mysql://([^:]+):([^@]+)@([^/]+)/([^\?]+)#", $database_dsn, $matches)) { + $date = date("Ymd"); + return + shell_exec("mysqldump -uUSER -pPASS -hHOST DATABASE | gzip > db-$date.sql.gz") . + "\n\nDatabase dump should now be sitting in db-$date.sql.gz in the shimmie folder"; + } + else { + return "Couldn't parse database connection string"; + } + } private function get_branches() { $data = shell_exec("svn ls http://svn.shishnet.org/shimmie2/branches/"); $list = array();