1

is there a way to clean, delete all the wiki pages so i can have a clean index, with only the pages i have created ?

gustavgans
  • 5,141
  • 13
  • 41
  • 51
Ernest
  • 962
  • 3
  • 12
  • 28
  • 1
    It is not entirely clear, if the request is to keep already existing custom pages, or if you ask to just get rid of all wiki pages as most answers suggest. Sure thing, it's a matter of taste to keep all the pages, but some like i.e. TitelIndex or RecentChanges could be part of any wiki, so you'll possibly re-invent them sooner or later. Why not customize them according to your likings right-way? – hasienda Mar 26 '13 at 12:15

4 Answers4

3

You can hack around trac-admin like this:

#!/bin/sh

# extract the page list from trac (this filter matches only CamelCase words or numbers,
# it will blow if there are pages which does not fit into this scheme)
for site in `trac-admin /path/to/trac wiki list | sed -e 's/\([a-zA-Z0-9]*\).*/\1/'`
do
    # and remove every single page
    trac-admin /path/to/trac wiki remove $site
done
Rudi
  • 19,366
  • 3
  • 55
  • 77
  • Just used this command to remove **ALL** wiki pages. Thanks for this snippet. Be carefull, it removes **every** page! Not only the auto generated ones. – Martin Krung Jun 04 '15 at 17:44
2

Precaution: Make a verified-good backup before, the cleanup of user changes to standard pages is final *).

Provided you can gain direct db access you should type the following simple SQL statement:

SELECT name FROM wiki WHERE author='trac';

It returns names of all wiki pages

  1. created by Trac itself (automatically on Trac environment creation alias 'init')
  2. imported, loaded or upgraded via trac-admin CLI later on (trac-admin <env> wiki <action>)

You may change, i.e. exclude some pages by extending the statement with further conditions in appropriate SQL syntax.

When a SELECT returns exactly the pages you're after, all you have to do is changing the same statement into a DELETE:

DELETE FROM wiki WHERE author='trac';

All but your custom wiki pages will be gone this second.

*) Original content could still be restored at any time by just executing the following command in a terminal session with appropriate permissions:

trac-admin <env> wiki upgrade
Martin Krung
  • 1,098
  • 7
  • 22
hasienda
  • 2,390
  • 1
  • 13
  • 16
0

If you use sqlite as database (standard for trac). Use this command to delete wiki entries with author trac:

sqlite3  /your/path/to/trac.db "DELETE FROM wiki WHERE author='trac'"
Martin Krung
  • 1,098
  • 7
  • 22
0

You may simply execute:

$ trac-admin /path/to/trac wiki remove *

If you want to be more selective using a graphical tool, you can use sqlitebrowser available for both linux and windows.

Christer
  • 9
  • 1
  • How would you avoid deleting user pages here? You suggestion would delete simply all pages, what is clearly *not* OP intention. Although done on environment initialization this would be ok. Admittedly the question is not totally clear in this respect. – hasienda Mar 26 '13 at 11:59
  • This command is not working: `Error: Invalid arguments` and its not the answer to this question too – Martin Krung Jun 04 '15 at 17:36