You are here: Foswiki>System Web>TrashPlugin (2026-03-17, ProjectContributor)Edit Attach
Maintain the Trash web
On this page:
This plugin lets you empty the trash bin on a regular base or immediately on request. By default deleting a topic, an attachment or a web, items are moved to the Trash.WebHome. It will stay there for recovery until the trash is emptied. Cleaning up the trash bin will wipe out items and their history from the store permanently, that is the operation can't be reverted anymore, even not by checking out a previous revision.
For this reason cleaning up the trash can only be performed by an admin user under the assumption they know better what they are doing.
TrashPlugin supports having local Trash webs, that is a subweb called "Trash" of a current web. Given you created a web MyWeb.Trash it will be detected and used as trash instead of the global Trash web where all content goes normally. A trash web can be created using the _TrashTemplate web. The currently used trash web is then made available in the preference setting %TRASHWEB%.
The REST handler cleanUp may be used to permanently delete items from the trash. You can add it to a cronjob but also call it manually as required. Use the {Expire} configuration parameter to defined the time period of items kept in the trash. Any topic, attachment or web moved to the trash older than the given time period will be removed permanently.
To perform regular maintenance automatically add a cron job calling the cleanUp REST handler of TrashPlugin.
0 0 * * * cd <foswiki-dir>/bin && ./rest /TrashPlugin/cleanUp
To clean up the trash of all virtual hosts installed via VirtualHostingContrib use
0 0 * * * cd <foswiki-dir>/tools && ./virtualhosts-rest /TrashPlugin/cleanUp
Optionally add an "Empty Trash" button to Trash.WebHome.
%BUTTON{"%MAKETEXT{"Empty Trash"}%"
icon="fa-trash"
href="%SCRIPTURLPATH{"rest"}%/TrashPlugin/cleanUp?redirectto=%WEB%.%TOPIC%&expire=0&web=%WEB%"
}%
You may also add a "Delete Attachments" button to TrashAttachment to only delete the attachments.
%BUTTON{"%MAKETEXT{"Delete Attachments"}%"
icon="fa-trash"
href="%SCRIPTURLPATH{"rest"}%/TrashPlugin/cleanUp?topic=%WEB%.%TOPIC%&redirectto=%WEB%.%TOPIC%&expire=0&web=%WEB%&mode=attachments"
}%
Parameters of the cleanUp handler:
| Parameter | Description | Default |
|---|---|---|
| expire | time period to check trash items for, any older item will be deleted permanently | see {TrashPlugin}{Expire} configuration setting |
| web | name of a trash web to perform the actions | all trash webs found |
| mode | specifies the item types to be deleted; values: all, topics, attachments, webs | all |
| includetopic | regular expression for topic items to be deleted | |
| excludetopic | regular expression for topic items spared | |
| includeattachment | regular expression for attachments to be deleted | |
| excludeattachment | regular expression for attachments spared |
Note that there are standard parameters to REST handlers which might be used as well:
redirectto: navigate to the given web.topic or url after the REST handler has finished topic: web.topic where to perform the handler Instead of adding the above buttons to the Trash WebHome and TrashAttachment topic you may also assign the following view templates to Trash.WebHome:
* Set VIEW = trash
and to Trash.TrashAttachment
* Set VIEW = trashattachment
Instead, ff you are using AutoTemplatePlugin, you may assign these two templates with the following rule:
$Foswiki::cfg{Plugins}{AutoTemplatePlugin}{ViewTemplateRules} = {
...
'.*Trash.WebHome' => 'trash',
'.*Trash.TrashAttachment' => 'trashattachment',
...
};
Note that this will assign the templates to any Trash web on the system, not only the main trash, but also any additional trash webs created elsewhere.
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.
You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki perl tools/extension_installer <NameOfExtension> install
If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
None
| 21 Oct 2025: | added templates for trash webhome and attachments |
| 13 Jun 2025: | added more parameters to cleanUp REST handler |
| 17 Mar 2025: | search for trash web in all parent webs |
| 30 Apr 2024: | delete attachments based on movedwhen instead of date |
| 26 Jan 2024: | added translations |
| 05 Mar 2022: | added support for custom Trash webs |
| 05 Oct 2021: | make deleting attachments more robust |
| 11 Feb 2021: | implemented custom trash webs: this allows to have local Trash subwebs |
| 24 Oct 2017: | don't delete WebStatistics from trash |
| 30 Jun 2017: | fixed deletion of webs in trash |
| 14 Jun 2016: | added parameter to configure which topics should be exempted from trashing; adding WebLeftBar by default now |
| 29 Aug 2014: | fully specify rest security |
| 04 Apr 2014: | flag rest handlers that don't require authentication |
| 05 Sep 2013: | fixed tainted issue |
| 06 Aug 2013: | initial release |
| Author | Michael Daum |
| Version | 5.00 |
| Release | 17 Mar 2026 |
| Description | Maintain the Trash web |
| Repository | https://github.com/foswiki/TrashPlugin |
| Copyright | © 2013-2026 Michael Daum |
| License | GPL (Gnu General Public License) |
| Home | Foswiki:Extensions/TrashPlugin |
| Support | Foswiki:Support/TrashPlugin |
Edit | Attach | Print version | History: r3 < r2 < r1 | Backlinks | View wiki text | Edit wiki text | More topic actions
Topic revision: r1 - 2026-03-17, ProjectContributor
Copyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback