Skip to content

Terminating a cPanel account without losing the data you still need to keep

A removeacct call wipes home, databases, mail, and DNS in one motion. A short checklist for archiving the bits you must retain before the account row disappears.

The customer asked for cancellation, billing closed the contract, and the account is queued for removal. Two weeks later the auditor asks for the access logs from the period the account was active, or the customer comes back asking for a copy of their site for handoff to a new vendor. If removeacct ran without an archive step, neither request has an answer. Termination is irreversible by design; the workaround is to make the archive step non-optional.

What’s happening

removeacct deletes /home/<user>, drops every MySQL database owned by the account, purges /var/cpanel/users/<user>, removes DNS zones from named, clears Exim queues for the account’s domains, and updates /etc/userdomains. None of this hits the backup system in real time — your nightly Borg, Acronis, or cPbackup run is your only safety net, and that net has holes if the cancellation happens within the retention window. Worse, customer data can include records you have a regulatory obligation to retain past the account life — invoices, audit logs, support tickets — and the WHM interface does nothing to surface that.

How to verify

Before you press the button, inventory what’s actually on disk and in databases:

pkgacct user=acme
whmapi1 accountsummary user=acme
whmapi1 list_dbs user=acme
ls -la /home/acme/
mysqldump --databases $(whmapi1 list_dbs user=acme --output=json | jq -r '.data.mysql_databases[]')

pkgacct builds a full account archive in /home/cpmove-acme.tar.gz — site files, databases, mail, DNS zone, account metadata. This is the canonical handoff artifact. Generate it before any termination, even when nobody asked.

The fix

  1. Make pkgacct mandatory in your termination runbook. The archive lives outside /home/acme, so it survives removeacct. Copy it to your offsite retention bucket before proceeding.
  2. Capture access and error logs separately — /usr/local/apache/logs/access_log and domlogs/ for the account. These do not go into the pkgacct archive. Tar them into a sidecar bundle named with the account and the cancellation date.
  3. Flag accounts under regulatory hold in /var/cpanel/users/<user> with a sentinel file (HOLD_UNTIL_YYYY-MM-DD) that your termination script reads before calling removeacct. The script refuses to proceed when the file exists.
  4. Defer the actual delete by 14 days. Suspend immediately, archive immediately, then schedule removeacct for a future date. If the customer returns within that window, unsuspending is free; if they don’t, the disk reclaim is the same.

Retention obligations around terminated accounts are exactly the kind of policy Stack Harbor’s cPanel and WHM management practice writes into operational runbooks so the audit trail is intact without slowing the team down.