A server takes a full backup every Sunday night. The disk fails on Thursday afternoon, after Wednesday night's backup. Which backup sets are needed if the weekday backups are (a) incremental, (b) differential? How much work is lost?
Backups protect data against disk failure, deletion, ransomware and disasters. Know full, incremental and differential backups and what each restore needs, rotation (GFS), the 3-2-1 rule, media, the tools tar, cpio, dd, dump/restore and rsync, cron scheduling, verification, RPO and RTO.
A backup is a copy of data kept separately so that the original can be restored after it is lost or damaged. Data are lost through hardware failure (a disk crash, a dead controller), human error (an accidental rm -r, an overwritten file), software bugs and file-system corruption, malware and ransomware, theft, and disasters such as fire or flood. For an organisation like a housing board, records that cannot be recreated — allotments, payments, legal documents — make backups a legal and operational necessity.
| Type | Copies | Backup time and size | To restore you need |
|---|---|---|---|
| Full | Every selected file | Slowest, largest | Just the one full backup |
| Incremental | Files changed since the last backup of any type (full or incremental) | Fastest, smallest | The last full backup plus every incremental since, applied in order |
| Differential | Files changed since the last full backup | Grows every day until the next full | The last full backup plus only the latest differential |
Incrementals minimise backup time but make restores long and fragile — lose one incremental in the chain and every later change is gone. Differentials trade larger daily backups for a two-step restore. On Windows the archive bit keeps track: a file's bit is set when it changes; full and incremental backups clear it, differential backups leave it set (so the next differential copies the file again).
A backup strategy states what is backed up, how often, by which method, onto what media, where copies are kept and for how long (the retention policy). A common pattern is a weekly full backup with daily incrementals or differentials in between, plus monthly copies kept long-term.
Grandfather–father–son (GFS) is the classic rotation scheme. The sons are daily backups (say Monday to Thursday), reused every week. The fathers are weekly full backups (the Friday sets), reused every month. The grandfathers are monthly full backups, kept for a year or longer and usually stored offsite. With 4 daily, 5 weekly and 12 monthly sets, 21 tapes cover a whole year while still allowing a restore from any day of the past week, any week of the past month and any month of the past year. (The Tower of Hanoi scheme is a cleverer rotation that keeps progressively older copies with fewer media.)
The 3-2-1 rule: keep at least 3 copies of the data (the original plus two backups), on 2 different types of media (say disk and tape, or disk and cloud), with 1 copy offsite. A modern extension is 3-2-1-1-0: also keep 1 copy offline or immutable (air-gapped tape, object-lock cloud storage) that ransomware cannot reach, and have 0 errors when backups are verified.
| Medium | Strengths | Weaknesses |
|---|---|---|
| Magnetic tape (LTO) | Lowest cost per terabyte; LTO-9 holds 18 TB native (45 TB compressed); shelf life of decades; offline by nature, so safe from ransomware | Sequential access — slow to find one file; needs drives and libraries. Linux names: /dev/st0 (rewinds after use), /dev/nst0 (non-rewinding) |
| External hard disk / NAS | Cheap, fast, random access; easy to automate | If left connected it can be encrypted by ransomware; mechanical and fragile |
| SSD / flash | Fastest; shock-resistant | Highest cost per GB; not ideal for long unpowered storage |
| Optical (CD 700 MB, DVD 4.7 GB, Blu-ray 25 GB per layer) | Write-once, so tamper-evident; durable archival discs exist | Small capacity; slow |
| Cloud / object storage | Automatically offsite; scales; archive tiers are very cheap; object-lock immutability | Depends on network bandwidth for large restores; ongoing cost; data leaves your premises |
Tape libraries and autoloaders hold many cartridges and swap them robotically; a virtual tape library (VTL) emulates tape on disk for speed. Whatever the medium, label it, record what is on it, and test that it can actually be read.
tar (tape archiver) bundles files and directories, with their owners, permissions and timestamps, into one archive file or tape. Options may be bundled after a single dash. The one rule to remember: f must be immediately followed by the archive name.
| Option | Meaning |
|---|---|
| c | Create a new archive |
| x | Extract files from an archive |
| t | List (table of contents) without extracting |
| v | Verbose — show each file |
| f name | Use the archive file or device name |
| z / j / J | Compress or decompress with gzip / bzip2 / xz |
| r, u | Append files / add only newer files (uncompressed archives) |
| C dir | Change to directory dir before extracting or archiving |
| p | Preserve permissions (the default for root) |
| d (--compare) | Compare the archive with the file system — a verification step |
| g snapshot | GNU incremental backup using a snapshot (metadata) file |
tar -cvf /backup/home.tar /home/anita # create an archive
tar -tvf /backup/home.tar # list it, long format
tar -xvf /backup/home.tar -C /restore # extract into /restore
tar -czvf /backup/etc.tar.gz /etc # gzip-compressed (.tar.gz / .tgz)
tar -cjvf /backup/etc.tar.bz2 /etc # bzip2-compressed
tar -xzvf /backup/etc.tar.gz etc/hosts # extract just one member
tar -dvf /backup/home.tar # compare archive with the disk
# GNU incremental: the first run with a new snapshot file is a full (level 0) backup
tar -g /backup/home.snar -czf /backup/home-full.tar.gz /home
tar -g /backup/home.snar -czf /backup/home-inc1.tar.gz /home # only changes sincetar -cvfz a.tgz dir is wrong: it creates an archive called z.cpio (copy in/out) takes the list of file names on standard input, usually from find, which makes selection very flexible. It has three modes: -o copy-out (create an archive), -i copy-in (extract) and -p pass-through (copy a tree elsewhere). The Linux initramfs is a cpio archive.
find /home -depth -print | cpio -ov > /backup/home.cpio # create
cpio -it < /backup/home.cpio # list
cpio -idv < /backup/home.cpio # extract, making directories
find /data -depth -print | cpio -pdmv /mnt/newdisk # copy a treedd copies raw blocks from an input file (if=) to an output file (of=), with a block size (bs=) and an optional count. It knows nothing about files, so it can image whole disks or partitions, boot sectors included.
dd if=/dev/sda of=/dev/sdb bs=4M status=progress # clone a whole disk
dd if=/dev/sda1 bs=4M | gzip > /backup/sda1.img.gz # compressed partition image
gunzip -c /backup/sda1.img.gz | dd of=/dev/sda1 bs=4M # restore it
dd if=/dev/sda of=/backup/mbr.bin bs=512 count=1 # save the MBR (first sector)
dd if=/backup/mbr.bin of=/dev/sda bs=446 count=1 # restore only the boot codeif and of overwrites the source without asking. Image only unmounted (or read-only) file systems, otherwise the copy may be inconsistent.dump backs up a whole ext2/3/4 file system by reading the device directly; restore reads it back (XFS has xfsdump/xfsrestore). Dump has levels 0–9: level 0 is a full backup, and a level-n dump copies every file that changed since the most recent dump of a lower level. The u option records each dump's date and level in /etc/dumpdates. (The fifth field of /etc/fstab is the flag that tells dump whether to back up that file system.)
dump -0uf /dev/nst0 /home # level 0 (full) to tape, record in /etc/dumpdates
dump -1uf /backup/home.1 /home # level 1: everything changed since the level 0
restore -tf /backup/home.1 # list the contents
restore -if /backup/home.0 # interactive: browse and pick files
restore -xf /backup/home.0 ./anita/report.txt # extract a named file
cd /mnt/newhome && restore -rf /backup/home.0 # rebuild a freshly made file systemChoosing levels gives different strategies. Sunday 0, then level 1 every other day behaves like differential backups (each level 1 copies everything since Sunday). Sunday 0, Monday 1, Tuesday 2, Wednesday 3… behaves like incremental backups (each copies only what changed since the day before). To restore, apply the level 0 and then, working forward, every later dump whose level is lower than the level of each dump made after it (the newest dump is always needed).
rsync (Andrew Tridgell and Paul Mackerras, 1996) synchronises a destination with a source, locally or over SSH. Its delta-transfer algorithm compares rolling checksums of file blocks and sends only the parts that differ, so repeated backups of large trees are fast.
rsync -avz /home/ backup@nas:/srv/backup/home/ # -a archive, -v verbose, -z compress
rsync -av --delete /data/ /mnt/usb/data/ # mirror: also delete removed files
rsync -avn --delete /data/ /mnt/usb/data/ # -n = dry run: show what would happen
rsync -a --delete --link-dest=/backup/2026-12-02 /home/ /backup/2026-12-03/
# unchanged files become hard links to yesterday's copy: every day looks like a
# full backup but only changed files use new space (the rsnapshot / Time Machine idea)-a (archive) = -rlptgoD: recursive, keep symlinks, permissions, times, group, owner and device files. Mind the trailing slash: rsync -a src/ dst/ copies the contents of src into dst, while rsync -a src dst/ creates dst/src.Larger sites use backup suites — Bacula and Amanda (open source, client–server, tape libraries), Borg and restic (deduplicating and encrypted), Clonezilla (disk imaging), Veeam (virtual machines), Windows Server Backup (wbadmin) and macOS Time Machine. Databases need their own tools (mysqldump, pg_dump) or snapshots, plus transaction logs for point-in-time recovery, because copying the files of a running database gives an inconsistent backup.
Backups must run automatically. cron runs commands at set times; each user edits a crontab with crontab -e (-l lists it, -r removes it). Every line has five time fields followed by the command.
| Field | Allowed values | Examples |
|---|---|---|
| Minute | 0–59 | 30 · */15 (every 15 minutes) |
| Hour | 0–23 | 2 · 9-17 (a range) |
| Day of month | 1–31 | 1 · 1,15 (a list) |
| Month | 1–12 or jan–dec | * (every month) |
| Day of week | 0–7 (0 and 7 are Sunday) or sun–sat | 1-5 (Monday to Friday) |
# m h dom mon dow command
# incremental backup, Monday to Saturday at 02:30
30 2 * * 1-6 /usr/local/bin/incr-backup.sh
# full backup, Sunday at 23:00
0 23 * * 0 /usr/local/bin/full-backup.sh
# monthly backup, 01:00 on the 1st
0 1 1 * * /usr/local/bin/monthly-backup.sh
# every 15 minutes during office hours, Monday to Friday
*/15 9-17 * * 1-5 rsync -a /data/ /mnt/nas/data/
# a dated archive: the percent sign must be escaped inside a crontab
0 3 * * * tar -czf /backup/etc-$(date +\%F).tar.gz /etc
# special string, the same as 0 0 * * *
@daily /usr/local/bin/cleanup.sh% ends the command (the rest becomes standard input), so date +%F must be written date +\%F. Comments must sit on lines of their own — cron passes everything after the five fields to the shell. If both day-of-month and day-of-week are restricted, cron runs the job when either matches. The system-wide /etc/crontab has an extra user field after the five time fields. Machines that are not always on should use anacron (catches up missed daily/weekly jobs); one-off jobs use at.tar -tvf), compare it (tar -dvf) or record and re-check checksums (sha256sum).When disaster strikes: identify the backup set needed (the full plus the right incrementals or differential), restore first to a separate location, verify the data, and only then put it into production. A bare-metal recovery boots rescue media, recreates the partitions, restores the image or files and reinstalls the boot loader.
Try the problem first, then reveal the working one step at a time.
A server takes a full backup every Sunday night. The disk fails on Thursday afternoon, after Wednesday night's backup. Which backup sets are needed if the weekday backups are (a) incremental, (b) differential? How much work is lost?
A file server holds 200 GB. A full backup runs on Sunday; from Monday to Saturday 10 GB of different data changes each day. Compare the week's backup storage and the restore set on Saturday night for incremental and for differential backups.
Back up /etc into a gzip-compressed archive named after today's date, list it, and restore only the hosts file into /tmp/restore without touching the live /etc.
A file system was dumped at level 0 on Sunday, 3 on Monday, 2 on Tuesday, 5 on Wednesday and 4 on Thursday. Which dumps does each one contain, and which must be restored after a failure on Friday?
Write crontab lines for: (a) an incremental backup at 02:30 every day; (b) a full backup at 23:00 every Sunday; (c) a monthly backup at 01:00 on the 1st; (d) an rsync every 15 minutes from 09:00 to 17:59, Monday to Friday.
From /backup/site.tar.gz, list the contents, then extract only var/www/index.html into /srv/restore. Why does the archive contain var/www/... rather than /var/www/...?
Write dd commands to (a) save the MBR of /dev/sda to a file, (b) restore only the boot code later without touching the partition table, and (c) make a gzip-compressed image of partition /dev/sda2.
A department takes a nightly backup at 01:00 to tape, which is sent to a vault 3 hours away. A server fails at 18:00, and a full restore from tape takes 5 hours. Management wants RPO ≤ 1 hour and RTO ≤ 4 hours. Are the targets met? Suggest changes.
A GFS scheme uses daily incremental tapes Monday to Thursday, a full backup every Friday on one of five weekly tapes, and a monthly full backup kept for a year. How many tapes are needed, and how far back can you restore?
10 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.