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();