[[PageOutline(2-2,Contents,pullout)]] = Migrate to new environment with another database {{{#!box warn **Notice:** The functionality provided by this plugin has been added to the Trac core in [trac:milestone:1.3.2] ([trac:#12299]). Trac 1.3.2+ provides the TracAdmin `convert_db` command. You should uninstall the plugin when upgrading to Trac 1.3.2 or later. }}} == Description The plugin allows you to migrate to a new Trac environment with another database. A common usage scenario is to convert a Trac environment based on SQLite to MySQL to accommodate performance requirements and concurrency requirements better. This plugin provides a `trac-migrate.py` script and the `migrate` command of `trac-admin`. See also: MsSqlBackendPlugin: a plugin to connect (not migrate) to a MS-SQL database server. == Bugs/Feature Requests Existing bugs and feature requests for TracMigratePlugin are [report:9?COMPONENT=TracMigratePlugin here]. If you have any issues, create a [/newticket?component=TracMigratePlugin new ticket]. [[TicketQuery(component=TracMigratePlugin&group=type,format=progress)]] == Download Download the zipped source from [export:tracmigrateplugin here]. == Source You can check out TracMigratePlugin from [/svn/tracmigrateplugin here] using Subversion, or [source:tracmigrateplugin browse the source] with Trac. == Usage without installation 1. Checkout or export latest source: {{{#!sh svn co https://trac-hacks.org/svn/tracmigrateplugin/0.12 /path/to/tracmigrateplugin }}} 2. If the new environment uses PostgreSQL or MySQL, create a database for this new environment. See [t:DatabaseBackend#BackendSpecificInstallationInstructions] (no running trac-admin is required). 3. Run `trac-migrate.py`: {{{#!sh cd /path/to/tracmigrateplugin ./trac-migrate.py /path/to/source /path/to/destination mysql://tracuser:password@localhost/trac }}} This would result in: {{{#!sh Copying tables: attachment table... 10 records. auth_cookie table... 9 records. cache table... 11 records. .... }}} == Installation This plugin is not needed to install as a Python library. See [#Usagewithoutinstallation usage without installation]. However, it is able to install as a Python library if you want to always be able to use `migrate` command. 1. Install the plugin for Trac 0.12 or later: {{{#!sh easy_install https://trac-hacks.org/svn/tracmigrateplugin/0.12 }}} 2. Enable the plugin in the `trac.ini` file of your source environment: {{{#!ini [components] tracmigrate.* = enabled }}} == Examples === Usage {{{#!sh $ ./trac-migrate.py Usage: trac-migrate.py [OPTIONS] SOURCE-TRACENV [DEST-TRACENV] DBURI Migrate to new environment with another database or another database without creating a new environment. Options: -i, --in-place migrate without creating a new environment Examples: $ trac-migrate.py /path/to/source /path/to/dest sqlite:db/trac.db $ trac-migrate.py /path/to/source /path/to/dest postgres://tracuser:password@localhost/trac?schema=destination $ trac-migrate.py /path/to/source /path/to/dest mysql://tracuser:password@localhost/trac $ trac-migrate.py --in-place /path/to/source sqlite:db/trac.db $ trac-migrate.py --in-place /path/to/source postgres://tracuser:password@localhost/trac?schema=destination $ trac-migrate.py --in-place /path/to/source mysql://tracuser:password@localhost/trac }}} === Migration to a new environment The syntax for migrating to a new environment is as follows: {{{#!sh $ ./trac-migrate.py /path/to/source-tracenv /path/to/destination-tracenv postgres://tracuser:password@localhost/trac?schema=destination Copying tables: attachment table... 10 records. auth_cookie table... 9 records. cache table... 11 records. component table... 5 records. enum table... 13 records. milestone table... 7 records. node_change table... 37 records. permission table... 17 records. report table... 11 records. repository table... 5 records. revision table... 35 records. session table... 2 records. session_attribute table... 19 records. ticket table... 35 records. ticket_change table... 110 records. ticket_custom table... 375 records. version table... 2 records. wiki table... 93 records. Copying directories: attachments directory... done. htdocs directory... done. templates directory... done. plugins directory... done. }}} === Migration to a new database without creating a new environment The syntax for migrating to a new database without creating a new environment is as follows: {{{#!sh $ ./trac-migrate.py --in-place /path/to/tracenv postgres://trac:password@localhost/trac?schema=new_schema Copying tables: attachment table... 31 records. auth_cookie table... 5 records. cache table... 17 records. component table... 6 records. enum table... 13 records. milestone table... 8 records. node_change table... 133876 records. permission table... 18 records. report table... 11 records. repository table... 80 records. revision table... 30076 records. session table... 5 records. session_attribute table... 15 records. system table... 3 records. tags table... 89797 records. tags_change table... 0 records. ticket table... 30009 records. ticket_change table... 353 records. ticket_custom table... 923 records. version table... 2 records. wiki table... 167 records. Back up conf/trac.ini to conf/trac.ini.migrate-1392451681 in /path/to/tracenv. }}} == Recent Changes [[ChangeLog(tracmigrateplugin, 3)]] == Author/Contributors '''Author:''' [wiki:jun66j5] [[BR]] '''Maintainer:''' [[Maintainer]] [[BR]] '''Contributors:'''