Recurring Cleanup with Profiles
Use this workflow when:
- you already know the cleanup shape you want
- you are tired of rerunning a long cleanup command
- you want a stable preset you can adjust over time
Do not start here if you have not yet done a narrow dry-run manually.
First validate the command shape with First Run or Rolling Retention.
Step 1: inspect available profile fields
Section titled “Step 1: inspect available profile fields”dmd profile fieldsThis shows the supported stored field names and the value shapes accepted by --set.
Step 2: create a baseline profile
Section titled “Step 2: create a baseline profile”Example:
dmd profile add nightly-dms \ --set include_ids=<id> \ --set keep_within=2w \ --set keep_last=20 \ --set preserve_cache=trueThis creates a baseline profile that can seed the preserve-cache before you introduce a narrow fetch window.
Replace <id> with a guild, category, guild text channel, DM, or Group DM ID.
If you want multiple IDs, use a comma-separated list such as include_ids=123,456.
The scope field is not required by the CLI. If you omit include_ids and exclude_ids, the profile uses the default cleanup scope: all eligible channels.
Step 3: inspect the stored result
Section titled “Step 3: inspect the stored result”dmd profile show nightly-dmsDo this immediately after creation so you can confirm:
- the right fields were stored
- nothing unexpected ended up in the profile
- the shape is what you want to maintain over time
Step 4: preview the profile as a dry-run
Section titled “Step 4: preview the profile as a dry-run”dmd clean --profile nightly-dms --dry-runThis is the most important step.
You want to verify:
- the selected scope is right
- the retention behavior looks right
- the number of affected messages and reactions is believable
Step 5: seed the real run once
Section titled “Step 5: seed the real run once”dmd clean --profile nightly-dmsThis first real run intentionally has no fetch_within limit. It lets the tool inspect the full scoped history and populate preserve-cache for kept messages.
Step 6: add the recurring fetch window
Section titled “Step 6: add the recurring fetch window”After the first real run has seeded preserve-cache, update the profile for the recurring schedule:
dmd profile update nightly-dms --set fetch_within=1dFor a daily run, 1d means the next run fetches the interval since the previous run while preserve-cache supplies older kept messages.
Use a wider fetch window if you want each recurring run to fetch the whole keep window too:
dmd profile update nightly-dms --set fetch_within=2w1dStep 7: evolve the profile instead of rewriting commands
Section titled “Step 7: evolve the profile instead of rewriting commands”Examples:
dmd profile update nightly-dms --set verbose=1dmd profile update nightly-dms --set max_messages=nonedmd profile update nightly-dms --unset fetch_withinUse this when you want to:
- widen or narrow retention
- change output defaults
- remove temporary limits
When preserve-cache matters here
Section titled “When preserve-cache matters here”If your recurring profile combines:
keep_last- limited
fetch_within - repeated runs
then preserve_cache usually becomes worth enabling.
That is the combination most likely to need continuity between runs.
See Preserve Cache for the detailed behavior.
Common mistakes
Section titled “Common mistakes”- Creating a profile before validating the command manually.
- Creating a profile without an explicit
include_idsorexclude_idsscope. - Forgetting to run the saved profile once in
--dry-run. - Storing too many output preferences before you know what level you actually want.
- Using
keep_lastwith a limited fetch window but no preserve-cache.