Duplicator Documentation

Documentation, Reference Materials, and Tutorials for Duplicator

Want it done for you?

Let the Duplicator experts migrate your WordPress site for you — quick, safe, and hassle-free.

Get Migration Help

Using WP-CLI with the Activity Log


Wondering how to export or clean up your activity log without opening wp-admin? The Activity Log plugin includes WP-CLI commands for exporting log data, reading events, and purging entries straight from the command line.

This guide covers using WP-CLI with the Activity Log plugin, including every available export, event, and purge flag.

Requirements: To use the Activity Log plugin, you’ll need an Activity Log license or the Duplicator Elite Bundle.

Requirements

WP-CLI must be installed on your server, with access to run it from the command line. The Activity Log plugin must be installed and activated. Run all commands from the root of your WordPress installation.

Export Command

The export command outputs activity log entries to the terminal or a file. Combine any of the flags below to filter the results.

wp duplicator-activity-log export

By default, this outputs all log entries as a formatted table. Add flags to filter the entries and change the output format.

Note: When Saving events is set to In the background (queued) in Activity Log » Settings » General » Advanced, new events are saved in batches every 15 minutes, except important events such as Activity Log Purged, which are saved right away. An export run right after an action may not include that action yet.

Export Flags

The following flags are available. All of them are optional, and they work in any combination:

  • --format=
    Output format. Accepts table (default), csv, or json.
  • --category_l1=
    Filter by top-level event category. Accepted values: user, content, media, plugin, theme, core, appearance, taxonomy, settings, activity_log. Plugin integrations add their own categories, such as backups and restores for Duplicator.
  • --severity=
    Filter by severity level. Accepted values: info, low, medium, high, critical.
  • --user_id=
    Filter events by a specific WordPress user ID.
  • --event_type=
    Filter by a specific event type code, for example: user_login_failed, plugin_activated, content_post_published.
  • --search=
    Search across event messages, usernames, and object names. Equivalent to the Search Events field in the admin. A whole IP address, for example --search=203.0.113.5, also finds the events recorded from that IP.
  • --date_from=
    Show events from this date onward. Use the YYYY-MM-DD or YYYY-MM-DD HH:MM:SS format. Dates and times are in UTC.
  • --date_to=
    Show events up to this date and time. Uses the same format as --date_from=. A date on its own includes that whole day, for example --date_to=2026-01-07.
  • --since_last_backup
    Export only the entries at or after the last Duplicator backup or restore recorded in the log. You can’t combine this flag with --date_from=. If the log holds no Duplicator backup, the command stops with the message No Duplicator backup is in the activity log. A backup whose deletion is logged no longer counts. Duplicator backups are logged by the Duplicator integration, which is on by default.
  • --via=
    Filter by how the change came in. Accepts ai_agent (an AI agent), app (any other application password), or cron (WP-Cron).
  • --site_id=
    On WordPress Multisite, filter events for a specific site by its blog ID. Defaults to the current site.
  • --fields=
    Comma-separated list of fields to display. This flag only applies to table format. CSV and JSON exports always include every field.

    Available fields for --fields=:
    id, date_gmt, severity, event_type, event_label, category_l1, category_l2, category_l3, message, user_id, user_login, user_role, object_type, object_id, object_name, ip_address, user_agent, request_method, request_uri, source, site_id, metadata, via, via_name.

Export Examples

Export all events as a CSV file:

wp duplicator-activity-log export --format=csv > activity-log.csv

Export only high severity events for a 7-day range:

wp duplicator-activity-log export --severity=high --date_from=2026-01-01 --date_to=2026-01-07

Export all failed login attempts as JSON:

wp duplicator-activity-log export --event_type=user_login_failed --format=json

Export all plugin events for a specific date range to a file:

wp duplicator-activity-log export --category_l1=plugin --date_from=2026-01-01 --date_to=2026-01-31 --format=csv > plugins-jan.csv

Export only specific fields for a lightweight CSV:

wp duplicator-activity-log export --format=csv --fields=date_gmt,user_login,severity,message > compact-log.csv

Export everything logged since the last backup:

wp duplicator-activity-log export --since_last_backup --format=csv > since-backup.csv

Purge Command

The purge command deletes activity log entries directly from the command line.

wp duplicator-activity-log purge

Running purge with no flags deletes every entry in the activity log. WP-CLI asks for confirmation before deleting, unless you add --yes. Each purge that deletes entries is recorded as an Activity Log Purged event (High severity) with the number of entries deleted, so after a full purge, and while Record activity is on, the log holds that one entry. The daily retention cleanup is not logged.

The following flags are available:

  • --older-than=<days>
    Delete only entries older than the given number of days, instead of deleting everything.
  • --yes
    Skip the confirmation prompt.

Note: Running wp duplicator-activity-log purge with no flags deletes the entire activity log, not just entries older than the number of days set in Keep events for. Add --older-than=<days> to delete only older entries. Automatic retention-based cleanup runs as a separate daily scheduled task (set in Activity Log » Settings » General) and is not the same action as this command. The --older-than= value must be a whole number above 0. With 0 or a value that isn’t a number, the command offers to delete every entry.

Purge Examples

Delete all log entries, with a confirmation prompt:

wp duplicator-activity-log purge

Delete entries older than 90 days:

wp duplicator-activity-log purge --older-than=90

Delete all entries without a confirmation prompt:

wp duplicator-activity-log purge --yes

Use these commands to clean up the activity log on demand. To delete every entry from wp-admin instead, go to Activity Log » Settings » Tools and click Purge All Logs. That button also records an Activity Log Purged event.

Event Commands

The event command reads events from the activity log. It has 3 subcommands: list, get, and stats.

Note: The event commands need an active Activity Log license. The export and purge commands don’t check for a license.

Event List

The list command shows events, newest first.

wp duplicator-activity-log event list

By default, this shows the 20 newest events as a table. The following flags are available. All of them are optional, and they work in any combination:

  • --severity=
    Filter by severity level. Accepted values: info, low, medium, high, critical.
  • --categories=
    Comma-separated categories. Each one is a domain, a domain/category pair, or a domain/category/subcategory path, for example wordpress/user. The category rows of the event stats command list the codes.
  • --event_type=
    Filter by a specific event type code, for example: user_login_failed.
  • --user_id=
    Filter events by a specific WordPress user ID.
  • --search=
    Search across event messages, usernames, and object names. A whole IP address, for example --search=203.0.113.5, also finds the events recorded from that IP.
  • --date_from=
    Show events from this date onward, in the YYYY-MM-DD or YYYY-MM-DD HH:MM:SS format. Dates and times are in UTC.
  • --date_to=
    Show events up to this date and time. Uses the same format as --date_from=. A date on its own includes that whole day.
  • --since_last_backup
    Show only the events at or after the last Duplicator backup or restore in the log. You can’t combine this flag with --date_from=. The first line of the output names that backup, in the form Since the last backup: <event> "<backup name>", <date> GMT. If the log holds no Duplicator backup, the command stops with the message No Duplicator backup is in the activity log.
  • --via=
    Filter by how the change came in. Accepts ai_agent (an AI agent), app (any other application password), or cron (WP-Cron).
  • --object_type=
    Filter by the type of object an event is about, for example: post, page, user, plugin.
  • --object_id=
    Filter by the ID of the object an event is about. This flag needs --object_type=.
  • --limit=
    How many events to show, from 1 to 100. Defaults to 20.
  • --before_id=
    Show older events: only IDs below this one, newest first.
  • --after_id=
    Show newer events: only IDs above this one, oldest first. You can’t combine --before_id= and --after_id=.
  • --format=
    Output format. Accepts table (default) or json.

When more events match than the limit shows, the table ends with a line such as More events: --before_id=4500. Then, add that flag to your next command to see the following page. When you page with --after_id=, the line reads More events: --after_id= followed by the newest ID shown.

Event Get

The get command shows one event with every stored field, its request details, and its changes and extra data. The event ID goes after the command:

wp duplicator-activity-log event get 4521

This command accepts the --format= flag, with table (default) or json.

Event Stats

The stats command counts the events of a date range, in total and by severity, category, event type, and how the change came in.

wp duplicator-activity-log event stats

The following flags are available:

  • --date_from=
    Start of the range, in UTC. Defaults to 7 days before --date_to=.
  • --date_to=
    End of the range, in UTC. Defaults to now. A date on its own includes that whole day. The range can be 90 days at most.
  • --format=
    Output format. Accepts table (default) or json.

Event Examples

Show everything logged since the last backup:

wp duplicator-activity-log event list --since_last_backup

Show the 50 newest high severity events:

wp duplicator-activity-log event list --severity=high --limit=50

Show everything WP-Cron changed, as JSON:

wp duplicator-activity-log event list --via=cron --format=json

Show every stored detail of one event:

wp duplicator-activity-log event get 4521

Count the events of January:

wp duplicator-activity-log event stats --date_from=2026-01-01 --date_to=2026-01-31

That’s it! You now know how to export, read, and clean up activity log data from the command line, without opening wp-admin.

Want to change how long entries stay in the log before the daily cleanup removes them? Check out our guide on changing the Activity Log settings.


Was this article helpful?


Related Articles

Don't Let Another Day Pass Unprotected

Every hour without proper WordPress backups puts your site at risk • Every delayed WordPress migration costs you performance and growth

Get Duplicator Now
Duplicator Plugin

Wait! Don't miss your
exclusive deal!

As a customer, you get 60% OFF

Try Duplicator free on your site — see why 1.5M+ WordPress pros trust us. But don't wait — this exclusive 60% discount is only available for a limited time.

or
Get 60% Off Duplicator Pro Now →