From bd68aae78a5d696e4ccb9c0d267486c283a6d9d2 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Fri, 18 Oct 2013 08:49:59 -0400
Subject: [PATCH] Resolved differences from svn merge to trunk and git master
---
server/plugins-available/backup_plugin.inc.php | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/server/plugins-available/backup_plugin.inc.php b/server/plugins-available/backup_plugin.inc.php
index 78be959..5da8fc0 100644
--- a/server/plugins-available/backup_plugin.inc.php
+++ b/server/plugins-available/backup_plugin.inc.php
@@ -80,7 +80,33 @@
$app->log('cp '.$backup_dir.'/'.$backup['filename'].' '.$web['document_root'].'/backup/'.$backup['filename'],LOGLEVEL_DEBUG);
}
}
-
+
+ //* Restore a MongoDB backup
+ if($action_name == 'backup_restore' && $backup['backup_type'] == 'mongodb') {
+ if(file_exists($backup_dir.'/'.$backup['filename'])) {
+ //$parts = explode('_',$backup['filename']);
+ //$db_name = $parts[1];
+ preg_match('@^db_(.+)_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}\.tar\.gz$@', $backup['filename'], $matches);
+ $db_name = $matches[1];
+
+ // extract tar.gz archive
+ $dump_directory = str_replace(".tar.gz", "", $backup['filename']);
+ $extracted = "/usr/local/ispconfig/server/temp";
+ exec("tar -xzvf ".escapeshellarg($backup_dir.'/'.$backup['filename'])." --directory=".escapeshellarg($extracted));
+ $restore_directory = $extracted."/".$dump_directory."/".$db_name;
+
+ // mongorestore -h 127.0.0.1 -u root -p 123456 --authenticationDatabase admin -d c1debug --drop ./toRestore
+ $command = "mongorestore -h 127.0.0.1 --port 27017 -u root -p 123456 --authenticationDatabase admin -d ".$db_name." --drop ".escapeshellarg($restore_directory);
+ exec($command);
+ exec("rm -rf ".escapeshellarg($extracted."/".$dump_directory));
+ }
+
+ unset($clientdb_host);
+ unset($clientdb_user);
+ unset($clientdb_password);
+ $app->log('Restored MongoDB backup '.$backup_dir.'/'.$backup['filename'],LOGLEVEL_DEBUG);
+ }
+
//* Restore a mysql backup
if($action_name == 'backup_restore' && $backup['backup_type'] == 'mysql') {
//* Load sql dump into db
--
Gitblit v1.9.1