delete all trac pages at once

こ雲淡風輕ζ 提交于 2019-12-21 06:25:45

问题


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 ?


回答1:


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



回答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



回答3:


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.




回答4:


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


来源:https://stackoverflow.com/questions/3978755/delete-all-trac-pages-at-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!