Ernest
Ernest

Reputation: 962

delete all trac pages at once

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 ?

Upvotes: 1

Views: 1425

Answers (4)

hasienda
hasienda

Reputation: 2390

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

Upvotes: 2

Martin Krung
Martin Krung

Reputation: 1127

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'"

Upvotes: 0

Christer
Christer

Reputation: 9

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.

Upvotes: 0

Rudi
Rudi

Reputation: 19940

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

Upvotes: 3

Related Questions