↑ ↓ select, Enter open, Esc close

Create a compressed tar backup with the date in the name

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
root@server
tar -czf /var/backups/example.com-httpdocs-$(date +%F).tar.gz -C /var/www/vhosts/example.com/httpdocs .

Creates an archive such as example.com-httpdocs-2026-10-09.tar.gz. With -C PFAD . the files are stored with relative paths and can later be extracted anywhere. Owners and permissions are stored as well. Ideal as a quick backup before an update.

Note: An archive with the same name is overwritten. This does not back up the database, which needs a separate dump.

Also searched as

  • tar.gz backup with date in filename
  • back up website as tar.gz
  • compress a directory linux
  • quick backup before update

Related one-liners

All in rsync and backup

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.