Back to lessons

Hosting Operations

List Largest Files in a Backup

You need to rank backup files by size.

Command

find backup -type f -printf '%s %p\n' | sort -nr | head

What changed

Nothing changes. The command prints file sizes and paths sorted largest first.

Danger

safe

When to use it

Use when backups are growing or a storage bill suddenly changes.

When not to use it

Do not delete files just because they are large; confirm age, ownership, and restore value first.

Undo or recovery

No undo needed because this command is read-only.

Expected output

A largest-first list of backup files with byte counts.

demo script

Disposable terminal steps

  1. find backup -type f -print | sort
  2. find backup -type f -printf '%s %p\n' | sort -nr | head

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find backup -type f -print | sort
backup/.snapshot
backup/app/config.yml
backup/content/index.md
backup/old-report.csv
backup/tmp/empty.cache
::exit-code::0
$ find backup -type f -printf '%s %p\n' | sort -nr | head
39 backup/app/config.yml
26 backup/content/index.md
13 backup/old-report.csv
0 backup/tmp/empty.cache
0 backup/.snapshot
::exit-code::0

YouTube Short

Rank backup files by size.

When backups grow unexpectedly, sort files by bytes before guessing what changed.

LinkedIn hook

Large backup files are where storage surprises usually start.

Question: When backup storage grows, do you rank files by size first?

experiments

A/B tests to run

Metric: save_rate

A: Backup storage grew.

B: Rank by bytes first.