]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
scripts to dump and restore the semanticscuttle database quickly - useful to keep...
authorChristian Weiske <cweiske@cweiske.de>
Fri, 8 Oct 2010 14:59:04 +0000 (16:59 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 8 Oct 2010 14:59:04 +0000 (16:59 +0200)
.gitignore
scripts/database-dump.php [new file with mode: 0644]
scripts/database-restore.php [new file with mode: 0644]

index 888ac2e1f9f7c9ab77f62b82628e013d48c75ed5..d84d93dbc86fb930b6359eca258d6f6b19fefef5 100644 (file)
@@ -1,3 +1,4 @@
 dist/
 build.properties
 package.xml
+semanticscuttle-dump.sql
diff --git a/scripts/database-dump.php b/scripts/database-dump.php
new file mode 100644 (file)
index 0000000..f4f04ac
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Dumps the semanticscuttle database into a file using mysqldump.
+ *
+ * This file is part of
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  GPL http://www.gnu.org/licenses/gpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
+require_once dirname(__FILE__) . '/../src/SemanticScuttle/header-standalone.php';
+
+passthru(
+    'mysqldump'
+    . ' -h' . escapeshellarg($GLOBALS['dbhost'])
+    . ' -u' . escapeshellarg($GLOBALS['dbuser'])
+    . ' -p' . escapeshellarg($GLOBALS['dbpass'])
+    . ' ' . escapeshellarg($GLOBALS['dbname'])
+    . ' > semanticscuttle-dump.sql'
+);
+?>
\ No newline at end of file
diff --git a/scripts/database-restore.php b/scripts/database-restore.php
new file mode 100644 (file)
index 0000000..6516e71
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Restores the semanticscuttle database from a given file.
+ *
+ * This file is part of
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  GPL http://www.gnu.org/licenses/gpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
+
+if (!isset($argv[1])) {
+    echo "Please pass the sql file to restore\n";
+    exit(1);
+}
+$file = $argv[1];
+if (!file_exists($file)) {
+    echo "The file does not exist\n";
+    exit(2);
+}
+
+require_once dirname(__FILE__) . '/../src/SemanticScuttle/header-standalone.php';
+
+passthru(
+    'mysql'
+    . ' -h' . escapeshellarg($GLOBALS['dbhost'])
+    . ' -u' . escapeshellarg($GLOBALS['dbuser'])
+    . ' -p' . escapeshellarg($GLOBALS['dbpass'])
+    . ' ' . escapeshellarg($GLOBALS['dbname'])
+    . ' < ' . escapeshellarg($file)
+);
+?>
\ No newline at end of file