Command line Reference
Custom baruwa commands are provided to enable scripting of house keeping tasks such as quarantine management and Database maintenance.
Note
This information is provided simply for reference and documentation purposes scheduled tasks are installed by default to perform these house keeping tasks for you, you do not have to create new cronjobs. For information on cronjobs that use these commands refer to Scheduled commands
Command options and help
These commands may take options to get details on the supported options run:
baruwa
baruwa COMMAND_NAME -h
The baruwa command has auto completions support meaning you can press tab to get the available options:
baruwa
Usage: baruwa [--config] [--log-level] [--cpu-profile|--mem-profile|--goroutine-profile] COMMAND [arg...]
Mail security system
Options:
-v, --version Show the version and exit
-c, --config The configuration file to use (default "development.toml")
-l, --log-level Log level to use (default "info")
-p, --cpu-profile Write cpu pprof profile to `directory`
-m, --mem-profile Write mem pprof profile to `directory`
-g, --goroutine-profile Write go routine pprof profile to `directory`
Commands:
serve Start the baruwa server
worker Start the baruwa worker
change-user-password Change a user's password
check-user-password Check a user's password
create-admin-user Create an administrator account
dump-mta-lookup-file Display the contents Exim cdb lookup files
prune-database Archives, then deletes old records, and trims archive
prune-quarantine Cleans the quarantine directory
release-quarantined-message Release a quarantined message
send-pdf-reports Send summary PDF reports
send-pdf-reports-ng Send summary PDF reports
send-quarantine-reports Send quarantine reports
send-quarantine-reports-ng Send quarantine reports
send-top-spammer-list Generates a list of top spammers and emails it
send-whitelist-data Generates a list of top ham senders for whitelisting
update-dkim-keys Creates or removes DKIM key files
update-metadata Generates SAML2 metadata
update-mta-lookup Generates cdb lookup files for the MTA
update-queue-stats Read the items in the queue and populate DB
update-rulesets Generates file based Scanner rulesets
update-sa-rules Update the Spamassassin rule descriptions
dmarcexpire Run the baruwa-dmarcexpire command
migrate Run database migrations
Run 'baruwa COMMAND --help' for more information on a command.
Quarantine management
baruwa prune-quarantine
Deletes quarantined files older than keep_messages_for setting.
This is set in the /etc/baruwa/production.toml file
Quarantine reports
baruwa send-quarantine-reports-ng
Generates an email report of the quarantined messages. This command allows you to specify the number of days the report should cover as well as the maximum number of messages to return. The following switches allow you to specify periods.
-o NUM_DAYS, --newer-than=NUM_DAYSReport on messages this number of days back-m MAX_MSGS, --max-records=MAX_MSGSMaximum number of messages to return-i ORG_ID, --org-id=ORG_IDProcess only this organization’s accounts-e EXCLUDE_ORG, --excluded-org=EXCLUDE_ORGExclude this organization’s accounts-n ORG_NAME, --organization-name=ORG_NAMEProcess only this organization’s accounts-d DOMAIN_NAME, --domain-name=DOMAIN_NAMEProcess only this domain’s accounts-u USER_NAME, --username=USER_NAMEProcess only this username’s report-f, --forceForce sending of reports even if hour is not in user or domain set timezone
Database maintenance
baruwa prune-database
Deletes records older than 30 days from the messages table of the database, and archives them to the archive table. It deletes records older than 90 days from the archives table. These defaults can be configured in the configuration file as the following options:
keep_messages_forkeep_archives_for
The following options allow you to specify the periods of the records that need to be processed.
-d--daysrecords older than this number are deleted from messages-a--adaysrecords older than this number are deleted from archives-w--windowarchive messages window size-v--verboseenable verbose output
Spamassassin rule description updates
baruwa update-sa-rules
Updates the Spamassassin rule descriptions in the database. This is depreciated
and has been replaced by the standalone command update-sa-rules
PDF reports
baruwa send-pdf-reports-ng
Sends PDF reports by email. This command allows you to specify the report type [domain, user], report period [daily, weekly, monthly] and the number of days to report on. The following switches allow you to specify the options.
-t REPORT_TYPE, --report-type=REPORT_TYPEReport type [user, domain]-p REPORT_PERIOD, --report-period=REPORT_PERIODReport period [daily, weekly, monthly]-d NUMBER_OF_DAYS, --number-of-days=NUMBER_OF_DAYSRestrict to number of days-i ORG_ID, --org-id=ORG_IDProcess only this organization’s accounts-e EXCLUDE_ORG, --excluded-org=EXCLUDE_ORGExclude this organization’s accounts-f, --forceForce sending of reports even if hour is not in user or domain set timezone
Mail queue Stats updates
baruwa update-queue-stats
Query the inbound and outbound queues and write stats to the database.
Create an administrator account
baruwa create-admin-user -u USERNAME -p PASSWORD -e EMAIL -t TIMEZONE
Create an administrator account
Change user password
baruwa change-user-password --username USERNAME
Changes an accounts password, This is the only way to change an administrator account’s password as it cannot be changed via the web interface.
Generate list of top spammers
baruwa send-top-spammer-list -e EMAIL [-m -s SPAMSCORE -p REPORT_PERIOD -d]
Generates a list of top spammers and emails or displays it.
-e EMAIL, --email=EMAILEmail address to send data to-m, --include-message-countInclude the number messages received-d, --dry-runPrint to stdout do not send email-n NUM, --messages-sent=NUMReturn senders with message counts equal to or greater than-s SPAMSCORE, --spam-score-threshold=SPAMSCORECount messages with spam scores equal to or greater than-p REPORT_PERIOD, --report-period=REPORT_PERIODReport period [daily, weekly, monthly]
Generate list of clean senders
baruwa send-whitelist-data -e EMAIL [-m -s SPAMSCORE -p REPORT_PERIOD -d]
Generates a list of top ham senders for whitelisting.
-e EMAIL, --email=EMAILEmail address to send data to-m, --include-message-countInclude the number messages received-d, --dry-runPrint to stdout do not send email-n NUM, --messages-sent=NUMReturn senders with message counts equal to or greater than-s SPAMSCORE, --spam-score-threshold=SPAMSCORECount messages with spam scores equal to or greater than-p REPORT_PERIOD, --report-period=REPORT_PERIODReport period [daily, weekly, monthly]
Create Scanner rulesets
baruwa update-rulesets
This will create or update the necessary Scanner rulesets.
Create MTA lookup files
baruwa update-mta-lookup
This will create or update the MTA CDB lookup files.
Dump MTA lookup file
baruwa dump-mta-lookup-file -f /var/lib/baruwa/data/db/routedata.cdb
This will display the contents of a CDB lookup file.
-f FILENAME, --filename=FILENAMELookup file to dump
Release Message from quarantine
baruwa release-quarantined-message -m _message_id_
This will release a message from the quarantine.
-m MESSAGEID, --messageid=MESSAGEIDMessage-ID of the message-d MSGDATE, --date=MSGDATEDate on which the message was processed-f FROMADDRESS, --from-address=FROMADDRESSFrom address to use-t TOADDRESS, --to-address=TOADDRESSTo address to release to-v, --verboseShow debug output