{"revision": {"id": "f3d081f8-2f95-11f1-8f35-e86a64d24d78", "node_id": "f3cf047c-2f95-11f1-8298-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "Trac Upgrade and Migration\r\n#############################\r\n\r\n.. contents::\r\n\r\nWe need to perform the following tasks:\r\n\r\n* Migrate Trac project to a new host\r\n* Upgrade from Trac==0.12.2 to Trac==1.0.1\r\n* Migrate tickets from old Trac project to new Trac project\r\n\r\n\r\nPossible solutions to migrate tickets from old Trac project to new Trac project:\r\n\r\n* Manual ticket migration\r\n\r\n  - allows for intelligent migration of tickets\r\n  - allows for important ticket proceedures to be properly documented in sphinx\r\n  - time consuming\r\n\r\n* Export old, import new\r\n\r\n  - moves ALL data to new project (even garbage)\r\n  - ticket numbers persist \r\n  - NOT time consuming\r\n\r\n* Research and develop a 'clone to new system' plugin\r\n\r\n  - allows for intelligent migration of tickets\r\n  - allows for important tasks to be documented in Ops Handbook\r\n  - time consuming (plugin development + manual migration) \r\n\r\n* Put old Trac into read-only, leave it running till it dies?\r\n\r\n  - manual migration of open tickets  \r\n  - simple as: chmod 000 pass_file\r\n  - operation headache, confusing to have two tracs\r\n  \r\n\r\nsetup development env from hot-copy of prod\r\n===============================================\r\n\r\n#. create hot-copy of trac:\r\n\r\n   .. code-block:: bash\r\n\r\n    trac-admin /path/to/projenv hotcopy /path/to/backupdir\r\n\r\n#. create a tar archive of hot backup:\r\n\r\n   .. code-block:: bash\r\n\r\n    tar -czvf trac-2013-07-2.tar.gz /cars/archive/trac-hot-copy-backup\r\n\r\n#. on your workstation scp tar archive:\r\n\r\n   .. code-block:: bash\r\n\r\n    cd ~\r\n    mkdir trac\r\n    cd trac\r\n    scp old-server:/cars/archive/trac-2013-07-2.tar.gz .\r\n\r\n#. unarchive:\r\n\r\n   .. code-block:: bash\r\n\r\n    tar xzvf trac-2013-07-2.tar.gz\r\n\r\n#. create virtualenv:\r\n\r\n   .. code-block:: bash\r\n   \r\n    cd trac-hot-copy-backup\r\n    virtualenv .env\r\n    source .env/bin/activate\r\n\r\n#. install Genshi==0.6 because Trac==0.12.2 breaks with Genshi==0.7:\r\n\r\n   .. code-block:: bash\r\n\r\n    pip install Genshi==0.6\r\n\r\n#. install Trac==0.12.2:\r\n\r\n   .. code-block:: bash\r\n\r\n    pip install Trac==0.12.2\r\n\r\n#. test setup:\r\n\r\n   .. code-block:: bash\r\n\r\n    tracd --port=8800 --env-parent-dir ~/trac/\r\n    \r\n#. open browser to http://127.0.0.1:8800\r\n\r\nupgrade from Trac==0.12.2 to Trac==1.0.0\r\n===============================================\r\n\r\n#. bring hot-copy tracd server offline\r\n\r\n#. Update the Trac Code to Trac==1.0:\r\n\r\n   .. code-block:: bash\r\n    \r\n    # optional, but these directories are no longer used \r\n    #rm -rf ~/trac/trac-hot-copy-backup/htdocs/ ~/trac/trac-hot-copy-backup/templates/\r\n    pip install Trac==1.0\r\n\r\n#. Upgrade the Trac environment:\r\n\r\n   .. code-block:: bash\r\n\r\n    trac-admin ~/trac/trac-hot-copy-backup upgrade\r\n    trac-admin ~/trac/trac-hot-copy-backup wiki upgrade\r\n\r\n#. test setup:\r\n\r\n   .. code-block:: bash\r\n\r\n    tracd --port=8800 --env-parent-dir ~/trac/\r\n\r\nupgrade again from Trac==1.0.0 to Trac==1.0.1\r\n===============================================\r\n\r\n#. bring hot-copy tracd server offline\r\n\r\n#. Update the Trac Code to Trac==1.0.1:\r\n\r\n   .. code-block:: bash\r\n\r\n    # optional, but these directories are no longer used \r\n    #rm -rf ~/trac/trac-hot-copy-backup/htdocs/ ~/trac/trac-hot-copy-backup/templates/\r\n    pip install Trac==1.0.1\r\n\r\n#. Upgrade the Trac environment:\r\n\r\n   .. code-block:: bash\r\n\r\n    trac-admin ~/trac/trac-hot-copy-backup upgrade\r\n    trac-admin ~/trac/trac-hot-copy-backup wiki upgrade\r\n\r\n#. test setup:\r\n\r\n   .. code-block:: bash\r\n\r\n    tracd --port=8800 --env-parent-dir ~/trac/\r\n\r\ndump ticket tables from hot-copy and import to new project\r\n====================================================================\r\n\r\n#. move to db directory:\r\n\r\n   .. code-block:: bash\r\n\r\n    cd ~/trac/trac-hot-copy-backup/db\r\n\r\n#. dump each table related to tickets:\r\n\r\n   .. code-block:: bash\r\n\r\n    sqlite3 trac.db \".dump ticket\" > trac_ticket.sql\r\n    sqlite3 trac.db \".dump ticket_change\" > trac_ticket_change.sql\r\n    sqlite3 trac.db \".dump ticket_custom\" > trac_ticket_custom.sql\r\n    sqlite3 trac.db \".dump ticket_template_store\" > trac_ticket_template_store.sql\r\n    sqlite3 trac.db \".dump attachment\" > trac_attachment.sql\r\n    sqlite3 trac.db \".dump milestone\" > trac_milestone.sql\r\n    sqlite3 trac.db \".dump pastes\" > trac_pastes.sql\r\n\r\n#. copy \\*.sql to the new trac project db directory\r\n\r\n#. become trac user:\r\n\r\n   .. code-block:: bash\r\n\r\n    sudo su - trac\r\n    bash\r\n\r\n#. import the tables:\r\n\r\n   .. code-block:: bash\r\n\r\n    cat trac_ticket.sql | sqlite3 trac.db\r\n    cat trac_ticket_change.sql | sqlite3 trac.db\r\n    cat trac_ticket_custom.sql | sqlite3 trac.db\r\n    cat trac_ticket_template_store.sql | sqlite3 trac.db\r\n    cat trac_attachment.sql | sqlite3 trac.db\r\n    cat trac_milestone.sql | sqlite3 trac.db\r\n    cat trac_pastes.sql | sqlite3 trac.db\r\n\r\n#. copy files/attachments directory from hot-copy to new Trac project.  Make sure owner:group is trac:trac:\r\n\r\n   .. code-block:: bash\r\n   \r\n    chown -R trac:trac files/attachments\r\n\r\n\r\ntrac database tables and explanations\r\n===============================================\r\n\r\nattachment\r\n KEEP - meta data for attachment files.  Also need underlying attachment directory.\r\n\r\nauth_cookie\r\n DROP - cookie session data for logged in users\r\n\r\ncache\r\n DROP - only record: 901198563|1|trac.wiki.api.WikiSystem.pages \r\n \r\ncomponent\r\n DROP - we plan to create new components via config management \r\n\r\nenum\r\n DROP - we plan to create new enums (priority, severity, ticket_type, resolution) via config management \r\n\r\nmilestone\r\n KEEP -  we have 7 records that need to be moved, Trac defaults to Milestone 1, 2, 3, 4\r\n\r\nnode_change\r\n DROP - empty \r\n\r\npastes\r\n KEEP - we need to install paste plugin\r\n\r\npermission\r\n DROP - we don't need to migrate old permissions. we need a plan to place in config management\r\n\r\nreport\r\n DROP - we don't need old reports. we might want to back them up as examples \r\n\r\nrepository\r\n DROP - empty \r\n\r\nrevision\r\n DROP - empty \r\n\r\nsession\r\n DROP - session data for when people logged in and what they did to the trac system\r\n\r\nsession_attribute\r\n DROP - session data for when people logged in and what they did to the trac system\r\n\r\nsubtickets\r\n KEEP - we might need to transform this data to work with new subticket plugin\r\n\r\nsystem\r\n DROP - version numbers of plugins and modules\r\n\r\nticket\r\n KEEP - tickets \r\n\r\nticket_change\r\n KEEP - ticket history\r\n\r\nticket_custom\r\n KEEP - ticket custom fields, might have garbage in this\r\n\r\nticket_template_store\r\n KEEP - ticket templates which auto fill body message with text, discuss this\r\n\r\nversion\r\n DROP - empty\r\n\r\nwiki\r\n DROP - discuss, we could migrate everything or we could migrate some pages  \r\n\r\n\r\n\r\nsubtickets migration to child ticket plugin\r\n==================================================\r\n\r\n.. code-block:: vim\r\n\r\n :%s/\"subtickets\"/\"ticket_custom\"/g\r\n", "source_format": "rst", "revision_number": 20, "created": 1373646751000}}