Shredder: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
Line 34: Line 34:
  do
  do
  date
  date
  SHREDDED=`rt-shredder --plugin "Tickets=query,id > 0;limit,100" --sqldump foo.sql 2>&1 | grep RT::Ticket | wc -l`
  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."
  echo "Shredded roughly $SHREDDED tickets."
  sleep 3 # let the system get a breath
  sleep 3 # let the system get a breath

Revision as of 12:53, 16 August 2011

As of 3.8.0 the Shredder extension is built into RT. This page documents how to get it working quickly for basic uses. You may also be interested in the information in ShredderControl.

Shredder Authorization

Only users with SuperUser rights can shred.

WebUI

The easiest way to shred objects (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.

CLI

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

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.

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

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

Comprehensive Help

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