Scrub for Craft CMS

Console commands

Every command respects the same protected fields, the same run ceiling and the same exclusion of drafts, revisions and trashed elements as the control panel. The guardrails live in the scanner, not in the form.

scrub/run/replace

A one-off replacement.

php craft scrub/run/replace \
  --find="Acme Ltd" \
  --replace="Acme Inc" \
  --mode=word \
  --sources=section:3 \
  --dry-run=1
OptionDefault
--findWhat to look for
--replaceWhat to put there. Omit it to delete the match
--modeplainplain, word or regex
--case-sensitive1
--preserve-case0Keep each match's own capitalisation (Pro)
--targetscontentComma separated: content, slugs, assets, database
--sourcessection:3,volume:1
--fieldsField handles, comma separated
--sitesSite handles or IDs
--elementsExplicit element IDs
--drafts0Include drafts
--revisions0Include revisions
--dry-run1

--dry-run defaults to 1. Running the command with no flags previews; it does not write. You have to ask for the write with --dry-run=0. A default that edits content because somebody forgot an argument is not a default worth having.

scrub/run/rule

Run a saved rule by handle, with the scope it was saved with.

php craft scrub/run/rule fix-legacy-links --dry-run=0

scrub/run/due

Run every scheduled rule that is currently due, and nothing else.

php craft scrub/run/due

Safe to call more often than the shortest cadence, so an hourly cron is fine even when every rule is monthly. This is the command to put in cron.

scrub/run/revert

Undo a run by its ID.

php craft scrub/run/revert 42

Values edited since the run are skipped and reported, exactly as in the control panel.

scrub/run/rules

List saved rules, their handles, and what each one does.

php craft scrub/run/rules