backup() { cp "$1" "$1.bak.$(date +%Y%m%d%H%M%S)"; }

Category: Terminal Configuration

backup() { cp "$1" "$1.bak.$(date +%Y%m%d%H%M%S)"; }

Create a timestamped backup of a file

Type `backup important.conf` and it creates `important.conf.bak.20260414190000`. The date format creates a sortable timestamp. Safer than overwriting a single .bak file each time.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.