· about 30 minutes · runs on ubuntu-26.04, alpine · unrated
An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.
/usr/local/bin/backup-data archives /srv/data into /var/backups every night and writes
"backup OK" to /var/log/backup-data.log. It has said "backup OK" every night for a year.
Last week someone needed a restore. The newest archive held a fraction of the files. Nobody can
say when that started. Looking at /var/backups, there have been no new archives for days — and
the log still says "backup OK" whenever someone runs it by hand.
The script honours three variables, so you can test it safely: BACKUP_SRC (default
/srv/data), BACKUP_DEST (default /var/backups) and BACKUP_LOG
(default /var/log/backup-data.log).
What is expected, and graded — the script is run against test data you will not see:
Keep the script in Bash.
The machine is checked, rebooted, and checked again. A check passes only if it passes both times.
| Check | Objective |
|---|---|
| 01_archives_names_with_spaces | Quote variables so file names with spaces survive |
| 02_fails_when_destination_unwritable | Make a script fail loudly: exit status, error messages, no false success |
| 03_fails_when_source_missing | Make a script fail loudly: exit status, error messages, no false success |
| 04_cron_can_run_it | Run a script from cron with a working environment |
Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).
man 1 bashman 5 crontab3 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Here they are, to answer in place:
What does `set -e` NOT catch?
A failing command on the left side of a pipeline, without pipefail
Without pipefail a pipeline's status is its last command's, so `false | true` succeeds and set -e does not fire. It is also suspended in if conditions and on the left of && or ||.
man 1 bash (set -e)
What PATH does a cron job get when the crontab sets none?
A minimal default such as /usr/bin:/bin
cron runs jobs with a small environment. Programs in /usr/local/bin or elsewhere must be called by full path, or PATH set at the top of the crontab.
man 5 crontab
What does this print?
cd /nonexistent-dir 2>/dev/null
echo "status=$?"
status=1
A failed cd returns 1 and the script carries on in the old directory unless set -e is on or the result is checked — the reason `cd "$dir" || exit 1` exists.
man 1 bash (cd) · executed in a sandbox