Index: /Users/shanec/svn/workspace/trunk/build/vendor/trac/trac/env.py
===================================================================
--- vendor/trac/trac/env.py	(revision 7745)
+++ vendor/trac/trac/env.py	(working copy)
@@ -33,7 +33,8 @@
 from trac.versioncontrol import RepositoryManager
 from trac.web.href import Href
 
-__all__ = ['Environment', 'IEnvironmentSetupParticipant', 'open_environment']
+__all__ = ['Environment', 'IEnvironmentSetupParticipant', 'open_environment',
+           'IBackupProvider']
 
 
 class IEnvironmentSetupParticipant(Interface):
@@ -59,7 +60,18 @@
         performed the upgrades they need without an error being raised.
         """
 
+class IBackupProvider(Interface):
+    """Extension point interface for components that implment support for
+       backup of database tables during environment upgrade."""
 
+    def supports_database(env):
+        """Returns a boolean if this provider supports the database
+        used by the environment.  The provider should check the
+        trac.database configuration."""
+
+    def backup(env, dest):
+        """Called when a new Trac environment is created."""
+
 class Environment(Component, ComponentManager):
     """Trac stores project information in a Trac environment.
 
@@ -71,6 +83,7 @@
      * wiki and ticket attachments.
     """   
     setup_participants = ExtensionPoint(IEnvironmentSetupParticipant)
+    backup_providers = ExtensionPoint(IBackupProvider)
 
     shared_plugins_dir = PathOption('inherit', 'plugins_dir', '',
         """Path of the directory containing additional plugins.
@@ -399,21 +412,17 @@
             yield username, name, email
 
     def backup(self, dest=None):
-        """Simple SQLite-specific backup of the database.
+        """Backup the databas using database specific backup providers.
 
         @param dest: Destination file; if not specified, the backup is stored in
                      a file called db_name.trac_version.bak
         """
-        import shutil
+        for provider in self.backup_providers:
+            if provider.supports_database(self):
+                provider.backup(self, dest)
+                return
+        raise TracError(_('No IBackupProvider supports this database type.'))
 
-        db_str = self.config.get('trac', 'database')
-        if not db_str.startswith('sqlite:'):
-            raise TracError(_('Can only backup sqlite databases'))
-        db_name = os.path.join(self.path, db_str[7:])
-        if not dest:
-            dest = '%s.%i.bak' % (db_name, self.get_version())
-        shutil.copy (db_name, dest)
-
     def needs_upgrade(self):
         """Return whether the environment needs to be upgraded."""
         db = self.get_db_cnx()
@@ -471,7 +480,26 @@
         return self._abs_href
     abs_href = property(_get_abs_href, 'The application URL')
 
+class DefaultBackupProvider(Component):
+    implements(IBackupProvider)
 
+    def supports_database(self, env):
+        db_str = env.config.get('trac', 'database')
+        return db_str.startswith('sqlite:')
+
+    def backup(self, env, dest=None):
+        """Simple SQLite-specific backup of the database.
+
+        @param dest: Destination file; if not specified, the backup is stored in
+                     a file called db_name.trac_version.bak
+        """
+        import shutil
+        db_str = env.config.get('trac', 'database')
+        db_name = os.path.join(env.path, db_str[7:])
+        if not dest:
+            dest = '%s.%i.bak' % (db_name, env.get_version())
+        shutil.copy (db_name, dest)
+
 class EnvironmentSetup(Component):
     implements(IEnvironmentSetupParticipant)
 

