% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math} % this also loads fontspec
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
  % xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
\hypersetup{
  pdftitle={trac-upgrade-and-migration},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}

\title{trac-upgrade-and-migration}
\author{}
\date{}

\begin{document}
\maketitle

\hypertarget{trac-upgrade-and-migration}{%
\section{trac-upgrade-and-migration}\label{trac-upgrade-and-migration}}

Trac Upgrade and Migration
\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#

.. contents::

We need to perform the following tasks:

\begin{itemize}
\tightlist
\item
  Migrate Trac project to a new host
\item
  Upgrade from Trac==0.12.2 to Trac==1.0.1
\item
  Migrate tickets from old Trac project to new Trac project
\end{itemize}

Possible solutions to migrate tickets from old Trac project to new Trac
project:

\begin{itemize}
\item
  Manual ticket migration

  \begin{itemize}
  \tightlist
  \item
    allows for intelligent migration of tickets
  \item
    allows for important ticket proceedures to be properly documented in
    sphinx
  \item
    time consuming
  \end{itemize}
\item
  Export old, import new

  \begin{itemize}
  \tightlist
  \item
    moves ALL data to new project (even garbage)
  \item
    ticket numbers persist
  \item
    NOT time consuming
  \end{itemize}
\item
  Research and develop a `clone to new system' plugin

  \begin{itemize}
  \tightlist
  \item
    allows for intelligent migration of tickets
  \item
    allows for important tasks to be documented in Ops Handbook
  \item
    time consuming (plugin development + manual migration)
  \end{itemize}
\item
  Put old Trac into read-only, leave it running till it dies?

  \begin{itemize}
  \tightlist
  \item
    manual migration of open tickets\\
  \item
    simple as: chmod 000 pass\_file
  \item
    operation headache, confusing to have two tracs
  \end{itemize}
\end{itemize}

\hypertarget{setup-development-env-from-hot-copy-of-prod}{%
\section{setup development env from hot-copy of
prod}\label{setup-development-env-from-hot-copy-of-prod}}

\begin{enumerate}
\item
  create hot-copy of trac:

  .. code-block:: bash

  trac-admin /path/to/projenv hotcopy /path/to/backupdir
\item
  create a tar archive of hot backup:

  .. code-block:: bash

  tar -czvf trac-2013-07-2.tar.gz /cars/archive/trac-hot-copy-backup
\item
  on your workstation scp tar archive:

  .. code-block:: bash

  cd \textasciitilde{} mkdir trac cd trac scp
  old-server:/cars/archive/trac-2013-07-2.tar.gz .
\item
  unarchive:

  .. code-block:: bash

  tar xzvf trac-2013-07-2.tar.gz
\item
  create virtualenv:

  .. code-block:: bash

  cd trac-hot-copy-backup virtualenv .env source .env/bin/activate
\item
  install Genshi==0.6 because Trac==0.12.2 breaks with Genshi==0.7:

  .. code-block:: bash

  pip install Genshi==0.6
\item
  install Trac==0.12.2:

  .. code-block:: bash

  pip install Trac==0.12.2
\item
  test setup:

  .. code-block:: bash

  tracd --port=8800 --env-parent-dir \textasciitilde/trac/
\item
  open browser to http://127.0.0.1:8800
\end{enumerate}

\hypertarget{upgrade-from-trac0.12.2-to-trac1.0.0}{%
\section{upgrade from Trac==0.12.2 to
Trac==1.0.0}\label{upgrade-from-trac0.12.2-to-trac1.0.0}}

\begin{enumerate}
\item
  bring hot-copy tracd server offline
\item
  Update the Trac Code to Trac==1.0:

  .. code-block:: bash

  \# optional, but these directories are no longer used \#rm -rf
  \textasciitilde/trac/trac-hot-copy-backup/htdocs/
  \textasciitilde/trac/trac-hot-copy-backup/templates/ pip install
  Trac==1.0
\item
  Upgrade the Trac environment:

  .. code-block:: bash

  trac-admin \textasciitilde/trac/trac-hot-copy-backup upgrade
  trac-admin \textasciitilde/trac/trac-hot-copy-backup wiki upgrade
\item
  test setup:

  .. code-block:: bash

  tracd --port=8800 --env-parent-dir \textasciitilde/trac/
\end{enumerate}

\hypertarget{upgrade-again-from-trac1.0.0-to-trac1.0.1}{%
\section{upgrade again from Trac==1.0.0 to
Trac==1.0.1}\label{upgrade-again-from-trac1.0.0-to-trac1.0.1}}

\begin{enumerate}
\item
  bring hot-copy tracd server offline
\item
  Update the Trac Code to Trac==1.0.1:

  .. code-block:: bash

  \# optional, but these directories are no longer used \#rm -rf
  \textasciitilde/trac/trac-hot-copy-backup/htdocs/
  \textasciitilde/trac/trac-hot-copy-backup/templates/ pip install
  Trac==1.0.1
\item
  Upgrade the Trac environment:

  .. code-block:: bash

  trac-admin \textasciitilde/trac/trac-hot-copy-backup upgrade
  trac-admin \textasciitilde/trac/trac-hot-copy-backup wiki upgrade
\item
  test setup:

  .. code-block:: bash

  tracd --port=8800 --env-parent-dir \textasciitilde/trac/
\end{enumerate}

\hypertarget{dump-ticket-tables-from-hot-copy-and-import-to-new-project}{%
\section{dump ticket tables from hot-copy and import to new
project}\label{dump-ticket-tables-from-hot-copy-and-import-to-new-project}}

\begin{enumerate}
\item
  move to db directory:

  .. code-block:: bash

  cd \textasciitilde/trac/trac-hot-copy-backup/db
\item
  dump each table related to tickets:

  .. code-block:: bash

  sqlite3 trac.db ``.dump ticket'' \textgreater{} trac\_ticket.sql
  sqlite3 trac.db ``.dump ticket\_change'' \textgreater{}
  trac\_ticket\_change.sql sqlite3 trac.db ``.dump ticket\_custom''
  \textgreater{} trac\_ticket\_custom.sql sqlite3 trac.db ``.dump
  ticket\_template\_store'' \textgreater{}
  trac\_ticket\_template\_store.sql sqlite3 trac.db ``.dump attachment''
  \textgreater{} trac\_attachment.sql sqlite3 trac.db ``.dump
  milestone'' \textgreater{} trac\_milestone.sql sqlite3 trac.db ``.dump
  pastes'' \textgreater{} trac\_pastes.sql
\item
  copy *.sql to the new trac project db directory
\item
  become trac user:

  .. code-block:: bash

  sudo su - trac bash
\item
  import the tables:

  .. code-block:: bash

  cat trac\_ticket.sql \textbar{} sqlite3 trac.db cat
  trac\_ticket\_change.sql \textbar{} sqlite3 trac.db cat
  trac\_ticket\_custom.sql \textbar{} sqlite3 trac.db cat
  trac\_ticket\_template\_store.sql \textbar{} sqlite3 trac.db cat
  trac\_attachment.sql \textbar{} sqlite3 trac.db cat
  trac\_milestone.sql \textbar{} sqlite3 trac.db cat trac\_pastes.sql
  \textbar{} sqlite3 trac.db
\item
  copy files/attachments directory from hot-copy to new Trac project.
  Make sure owner:group is trac:trac:

  .. code-block:: bash

  chown -R trac:trac files/attachments
\end{enumerate}

\hypertarget{trac-database-tables-and-explanations}{%
\section{trac database tables and
explanations}\label{trac-database-tables-and-explanations}}

attachment KEEP - meta data for attachment files. Also need underlying
attachment directory.

auth\_cookie DROP - cookie session data for logged in users

cache DROP - only record:
901198563\textbar1\textbar trac.wiki.api.WikiSystem.pages

component DROP - we plan to create new components via config management

enum DROP - we plan to create new enums (priority, severity,
ticket\_type, resolution) via config management

milestone KEEP - we have 7 records that need to be moved, Trac defaults
to Milestone 1, 2, 3, 4

node\_change DROP - empty

pastes KEEP - we need to install paste plugin

permission DROP - we don't need to migrate old permissions. we need a
plan to place in config management

report DROP - we don't need old reports. we might want to back them up
as examples

repository DROP - empty

revision DROP - empty

session DROP - session data for when people logged in and what they did
to the trac system

session\_attribute DROP - session data for when people logged in and
what they did to the trac system

subtickets KEEP but DROP - we might need to transform this data to work
with new subticket plugin

system DROP - version numbers of plugins and modules

ticket KEEP - tickets

ticket\_change KEEP - ticket history

ticket\_custom DROP - ticket custom fields, lots of garbage from old
plugins. We will be generating a migration from subticket to new
childticket plugin that will insert into this table.

ticket\_template\_store KEEP - ticket templates which auto fill body
message with text, discuss this

version DROP - empty

wiki DROP - discuss, we could migrate everything or we could migrate
some pages

\hypertarget{subtickets-migration-to-child-ticket-plugin}{%
\section{subtickets migration to child ticket
plugin}\label{subtickets-migration-to-child-ticket-plugin}}

dump out the data and edit with vim

.. code-block:: bash

sqlite3 trac.db sqlite\textgreater{} .mode csv sqlite\textgreater{} .out
trac\_subtickets.csv sqlite\textgreater{} SELECT child,parent FROM
subtickets; sqlite\textgreater{} .exit vim trac\_subtickets.csv

run the following search and replace transformations:

.. code-block:: vim

\%s/,/,``parent'',``\#/g \%s/\$/'');/g \%s/\^{}/INSERT INTO
``ticket\_custom'' VALUES(/g

rename

.. code-block:: bash

cp trac\_subtickets.csv trac\_ticket\_children.sql

\end{document}
