Hands-on task
A dated backup of the nginx configs
Write a script /usr/local/bin/backup-nginx that packs the /etc/nginx directory into the archive /var/backups/nginx/nginx-YYYYMMDD.tgz (today's date, no dashes, e.g. nginx-20260315.tgz). The script creates the /var/backups/nginx directory itself if it's missing. Don't type the date into the script by hand — it has to work tomorrow too. Run the script. It's handy to write the script in the Editor tab above the terminal — the /usr/local/bin directory is open on the left there.
- date +FORMAT
- command substitution
- tar
- mkdir -p
- config backup