开发者

delete all trac pages at once

is there a way to clean, delete all the wiki pages so i can have a clean 开发者_如何学Cindex, with only the pages i have created ?


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


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


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜