Shredder: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
(Updated to add reference to URI length overflow on large target ticket count)
(No difference)

Revision as of 19:57, 19 August 2011

Introduction

As of 3.8.0 the Shredder extension is built into RT.

This page documents how to get it working quickly for basic uses.

Shredder has web (WebUI) and command line (CLI) interfaces. Both are equivalent in terms of available search plugins and options to pick objects.

WebUI

Only users with SuperUser rights can shred through WebUI.

The easiest way to shred tickets (particularly tickets, users, attachments) is to build a custom search with your desired criteria in the WebUI. You will then have a chance to review and select specific objects then remove them from the database while a backup SQL dump is created.

Note that while the interface indicates it accepts DOS-like wildcards (* and ?) these are translated to the standard SQL wildcards of % and _ internally, and you may specify them directly if you prefer. Specifically this means that the claim * matches non-empty sequences is misleading since % will match null.

Don't use to delete many objects as shredder is quite slow and may hit browser or server timeout that will abort operation. A large number of target tickets may also result in a query to the web server that is larger than the maximum allowable URI length. Use the CLI instead.

CLI

You can use shredder from command line, here is a few commands to help you start:

perldoc RT/Shredder.pm
rt-shredder --help
rt-shredder --plugin help-Tickets
rt-shredder --plugin help-Users

See a few #Examples examples below.

Examples

Examples presented with shell commands, but the same can be performed in the WebUI.

Shred Deleted Tickets by Status and Age

You can run the following command by hand and see the results.

rt-shredder --plugin "Tickets=query,Status = 'Deleted' AND LastUpdated < '30 days ago';limit,100" --sqldump /{somepath}/shredder-restore-tickets.sql

Shred Users with no Tickets

Users with no tickets are users who have had their tickets deleted -- spam senders, or users whose tickets have been moved to another user.

rt-shredder --plugin "Users=no_tickets,1;status,any;replace_relations,Nobody;limit,5" --sqldump /{somepath}/shredder-restore-users.sql --force

Shredding many tickets

You may also be interested in the information in ShredderControl.

Shred ALL TICKETS

WARNING WARNING WARNING:

If for some reason you want to reset your entire RT instance's TICKETS AND TICKET DATA ONLY (and keep Scrips, Custom Fields, etc), you could do something like the following. This was useful for me when I wanted to take our production RT instance and duplicate it onto a development box but not have the huge database full of tickets and ticket-related data.

With shredder and shell script

Bourne shell syntax is shown below:

cd /tmp
while :
do
date
SHREDDED=`rt-shredder --plugin "Tickets=query,id > 0;limit,100" --force --sqldump foo.sql 2>&1 | grep RT::Ticket | wc -l`
echo "Shredded roughly $SHREDDED tickets."
sleep 3 # let the system get a breath
rm -f foo.sql # we don't care about restoring what we shredded in this case
if [ $SHREDDED -eq 0 ]; then
    break
fi
done

With rt-validator

Delete all tickets with SQL command:

DELETE FROM Tickets;

Use rt-validator to delete records that are broken now:

./sbin/rt-validator -c --resolve

With rt-delete-tickets-mysql from RT-Extension-Utils

Mark all tickets with status deleted with SQL command:

UPDATE Tickets SET Status = 'deleted';

Use the tool to delete tickets and everything related then check consistensy:

 ./sbin/rt-delete-tickets-mysql
 ./sbin/rt-validator -c

Afterward, you will probably want to do the "Shred Users with no Tickets" run as described above as well.

Shredder for RT 3.6 and older

For older releases extension available from CPAN. However, it's highly recommended to upgrade RT first and use built in solution.