TODO NOW:
-- Check for extensions, have DB rollback
+- Check for extensions
- Implement "group" filtering using blanche for limited rollouts.
- Remove "already migrated" cruft that will accumulate if we do small
--- /dev/null
+#!/bin/sh
+rm -Rf testdir*
--- /dev/null
+#!/bin/bash -e
+
+TESTNAME="backup_restore_mediawiki"
+source ./setup
+
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+cd "$TESTDIR"
+wizard backup
+
+# destroy some files
+FROB="includes/Setup.php"
+mv "$FROB" "$FROB.bak"
+echo "BOOM" > "$FROB"
+
+# destroy the database
+mysql $MYSQL_ARGS -e "DROP DATABASE \`$WIZARD_MYSQL_DB\`;"
+mysql $MYSQL_ARGS -e "CREATE DATABASE \`$WIZARD_MYSQL_DB\`;"
+
+BACKUP=`wizard restore | head -n1`
+wizard restore "$BACKUP"
+
+cmp "$FROB" "$FROB.bak"
+curl -s -L "http://$WIZARD_WEB_HOST$WIZARD_WEB_PATH/index.php" | grep "<title>"
+
--- /dev/null
+#!/bin/bash -e
+
+TESTNAME="upgrade_mediawiki_restore"
+source ./setup
+
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard upgrade "$TESTDIR"
+cd "$TESTDIR"
+BACKUP=`wizard restore | head -n1`
+wizard restore "$BACKUP"
+git describe --tags
d = deploy.Deployment(".")
d.verify()
d.verifyConfigured()
- d.application.backup(d, options)
+ d.backup(options)
def parse_args(argv, baton):
usage = """usage: %prog backup [ARGS] [DIR]
import sys
import distutils.version
-from wizard import command, deploy, git
+from wizard import command, deploy, git, shell, util
def main(argv, baton):
app.install(distutils.version.LooseVersion(version), options)
+ sh = shell.Shell()
+ message = "Autoinstall configuration of %s locker.\n\n%s" % (util.get_dir_owner(), util.get_git_footer())
+ util.set_git_env()
+ try:
+ message += "\nConfigured-by: " + util.get_operator_git()
+ except util.NoOperatorInfo:
+ pass
+ sh.call("git", "commit", "--allow-empty", "-a", "-m", message)
+
sh.call("git", "clone", "--shared", application.repository(options.srv_path), dir)
with util.ChangeDirectory(dir):
if version:
- sh.call("git", "checkout", app)
+ sh.call("git", "reset", "--hard", app)
# this command's stdin should be hooked up to ours
try:
configure_args = args[2:] + command.makeBaseArgs(options)
except shell.CallError:
raise Exception("Tag %s doesn't exist in repository" % tag)
sh.call("git", "reset", "--hard", tag)
- d.application.restore(d, backup, options)
+ d.restore(backup, options)
def parse_args(argv, baton):
usage = """usage: %prog restore [ARGS] ID
if options.dry_run:
logging.info("Dry run, bailing. See results at %s" % temp_wc_dir)
return
+ # perform database backup
+ d.backup(options)
# XXX: frob .htaccess to make site inaccessible
# XXX: need locking
# git merge (which performs a fast forward)
as such dir will generally not equal :attr:`location`.
"""
return self.application.parametrize(self, dir)
+ def backup(self, options):
+ """
+ Performs a backup of database schemas and other non-versioned data.
+ """
+ with util.ChangeDirectory(self.location):
+ return self.application.backup(self, options)
+ def restore(self, backup, options):
+ """Restores a backup. Destroys state, so be careful!"""
+ with util.ChangeDirectory(self.location):
+ return self.application.restore(self, backup, options)
def prepareConfig(self):
"""
Edits files in the deployment such that any user-specific configuration
+import os
+
from wizard import shell
def get_sql_credentials():
returned as a three-tuple (host, user, password).
"""
sh = shell.Shell()
+ host = os.getenv("WIZARD_MYSQL_HOST")
+ user = os.getenv("WIZARD_MYSQL_USER")
+ password = os.getenv("WIZARD_MYSQL_PASSWORD")
+ if host is not None and user is not None and password is not None:
+ return (host, user, password)
try:
return sh.eval("/mit/scripts/sql/bin/get-password").split()
except CallError: