GoAdmio

clean

Delete old backups, trash, session files, and expired mail to free up disk space

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/clean removes files that are no longer needed so they stop using disk space. In one run it:

It needs root. If you run it as another user, it re-runs itself with sudo.


Quick start

# Clean up files older than 14 days
/go/clean

[!WARNING] Everything this command deletes is deleted permanently. There is no confirmation, no dry run, and no recycle bin. Trash folders are emptied regardless of age, and --force removes backup archives regardless of age. Make sure the backups you need are stored somewhere other than the account home folders.


Syntax

# Delete backups older than 14 days
/go/clean

# Delete all backup archives and backup folders, regardless of age
/go/clean --force
Form Behavior
/go/clean Removes backup archives and folders in account home folders only if they are older than 14 days.
/go/clean --force Removes them regardless of age.

Options

Option Required Default Notes
--force No — Skips the 14-day age check for backup archives and backup folders in /home/<domain>/. Nothing else changes.

Other arguments are ignored. The option is detected by searching the whole argument list for the text --force, so any argument containing it, such as --forceful, also triggers force mode.


Output

The command prints nothing of its own. Any output comes from the commands it calls, such as reload.

Every run is logged with a timestamp, for example [Nov 20 03:00:01]# clean --force, to /var/log/go/clean.log.

The command sets no exit code of its own. It exits with the status of the last command it ran, so don't rely on it in scripts.


Examples

# Routine cleanup
/go/clean
# Free as much space as possible: delete every backup archive in the account folders
/go/clean --force
# Check what was run and when
tail -n 20 /var/log/go/clean.log
# Clean up every night at 03:00
0 3 * * * /go/clean
# Keep only 30 days of mail for a new account
/go/create --domain example.com --mailttl 30

Troubleshooting

Symptom Likely cause Fix
A needed backup archive disappeared It was a .tar.gz file, or a folder named *-backup-*, directly inside /home/<domain>/ and was older than 14 days, or --force was used. Restore from snapshot or restore. Keep backups outside the account home folders.
Old email keeps disappearing The account has a MailTTL of 1 or more days. Set MailTTL to 0 to disable mail cleanup for the account.
Nothing was deleted from /home/<domain>/ Files are older than 14 days only if they are more than 14 full days old, or they are not directly inside the account home folder. Check the file's age and location, or use --force.
Disk space didn't drop Most space is in www, databases, or logs, which this command doesn't touch. Use dbls to find large databases, or check the sizes of the account folders.
HTTP log statistics or DDoS history reset Normal. The command deletes httplog.db and ddos.db on every run. Run it less often if you need that history.
The command asks for a password You aren't root and sudo needs one. Run it as root, or from an account with passwordless sudo.

Details

What gets deleted

Paths below are relative to each account at /home/<domain>/.

Target Where Rule
Backup archives *.tar.gz files directly in /home/<domain>/ Older than 14 days. All of them with --force.
Backup folders Folders named *-backup-* directly in /home/<domain>/ Older than 14 days. All of them with --force.
SQLite backups /var/lib/sqlite/backup Anything older than 14 days. Not affected by --force.
Save files Files named *.save.? (for example config.save.1) anywhere under /home All of them, regardless of age.
PHP sessions Files in /var/lib/*/session Older than 3 days.
Mailbox trash /home/<domain>/mail/*/.Trash/* Everything, regardless of age.
Account trash /home/<domain>/.trash/* Everything, regardless of age.
Expired mail Files under /home/<domain>/mail Older than the account's MailTTL. See Mail retention.

Age is measured by each file's last-modified time. "Older than 14 days" means more than 14 full days.

The /var/lib/sqlite/backup rule has no file-type filter, so it can also match the folder itself if its modified time is old.

Mail retention

Each account has a MailTTL value in the Site table, in days. It is set with the --mailttl option of create and defaults to 0, which means mail is never deleted by age.

For each folder in /home that contains both www and mail, if MailTTL is 1 or more, every file under /home/<domain>/mail older than that many days is deleted. This covers all folders in the mail tree, not just the Inbox, so sent mail and archives are removed too.

Order of operations

  1. Re-run with sudo if not root, and log the call.
  2. Delete old (or, with --force, all) backup archives and backup folders in the account folders.
  3. Delete old SQLite backups, *.save.? files, and old PHP session files.
  4. Empty the mailbox trash and account trash.
  5. Delete /var/go/var/lib/mysql.
  6. Run reload with the message | Executed by clean.
  7. Empty /usr/local/goadmio/tmp, then delete /var/lib/sqlite/httplog.db and /var/lib/sqlite/ddos.db.
  8. Run /go/database, then set ownership of /var/lib/sqlite to go:go.
  9. Delete expired mail for every account with a MailTTL of 1 or more.

The command doesn't touch www, mail data that is within its retention period, MySQL databases, or SSL certificates.


See also

Command Description
cache Clear cached data files to free space and refresh state
clearsession Delete every active PHP session file from the server
reload Reload PHP-FPM and the active web server
backup Create a backup for all GoAdmio accounts (local and remote)
snapshot Restic-based per-domain snapshot backup and restore
restore Restore a GoAdmio backup from the command line
create Create a GoAdmio account from the command line
cron Set up main cron jobs in GoAdmio