Extracting information from Trac backup - statnet/computing GitHub Wiki

This is meant to be not a complete guide but a set of notes in case this know-how is needed later.

Backup location

The most recent available backup can be found on statnet.csde.washington.edu in directory /OLD-TRAC-STATNET/trac/.

The key file with the information about the wiki is an SQLite database found in /OLD-TRAC-STATNET/trac/statnet/db/trac.db, which stores pretty much everything (including the tickets and the wiki page contents) except for the binary attachments, to which it stores only the references.

Extraction recipes

Wiki pages

The following Python 3 code was executed to extract copies of the most recent versions of all Wiki pages. A directory named Statnet_wiki_pages was created outside of Python in the same directory as the copy of trac.db used.

import sqlite3
db = sqlite3.connect("trac.db")
cur = db.cursor();
cur.execute('''select name,text from wiki where (name,version) in (select name,max(version) from wiki group by name);''')

for name, text in cur: open("Statnet_wiki_pages/"+name+".wiki","w").write(text)