LPIC-2 System Maintenance: Backup, Restore, and User Notification
- Pick the right backup tool for the job — tar, rsync, dd, or dump/restore — instead of forcing one tool everywhere
- Drive rsync safely, including the trailing-slash rule, --delete mirrors, and --link-dest snapshots
- Notify logged-in users with wall and schedule or cancel a reboot with shutdown
- Set the correct login banner: /etc/motd after login versus /etc/issue and /etc/issue.net before login
Why one backup tool is never enough
Frame backup as tool selection: each tool answers a different question, so the skill is matching tool to job.
There is no single "backup command" on Linux, and that is by design. A backup tool makes a trade-off between portability, speed, and fidelity, and no one tool wins on all three. The LPIC-2 skill — and the real-world skill — is matching the tool to the job.
Think of it like a toolbox of containers for moving house. A cardboard box (
tar) is portable: anyone can carry it anywhere and open it later. A moving crew that only carries what changed since yesterday (rsync) is fast on repeat trips. A photograph of the whole room, every pixel (dd) is a perfect raw copy but huge and rigid. A labelled inventory taken in waves (dump/restore) records exactly what changed at each level. You would not photograph a room to move one chair, and you would not mail a moving crew across the country for a single archive.Here is the cheat-sheet you will spend the rest of the lesson earning:
- `tar` — bundle files into one portable archive (
backup.tar, often gzip'd to.tar.gz). Great for shipping a directory somewhere or keeping a dated snapshot file. - `rsync` — incremental copying, locally or over the network. Only transfers the differences, so the second run is fast. The workhorse for mirrors and repeat backups.
- `dd` — a raw block-level image of a whole disk or partition. Copies bytes, not files, so it captures partition tables, boot sectors, and unused space. Used for cloning disks and disk imaging.
- `dump`/`restore` — filesystem-level, leveled backups for ext2/3/4. Understands the filesystem directly and supports incremental "levels" (level 0 = full, higher = only changes since a lower level).
- `tar` — bundle files into one portable archive (
tar and dd — portable archives vs raw images
Build a portable tar archive and understand when only a dd block image will do.
Start with the two extremes: `tar` works at the file level (it copies files and their metadata), while `dd` works at the block level (it copies raw bytes off the device and ignores the concept of files entirely).
Example — not runnable on your lab box
tar -czvf /backup/etc-2026-06-23.tar.gz /etctar: Removing leading `/' from member names /etc/ /etc/hostname /etc/passwd /etc/ssh/sshd_config ...
- -c
- Create a new archive (as opposed to -x extract or -t list).
- -z
- Compress the archive with gzip (the .gz in the name). Use -j for bzip2, -J for xz.
- -v
- Verbose: print each file as it is added, so you can watch progress.
- -f
- The next argument is the archive Filename. Must come last among bundled flags.
One portable file now holds all of /etc. TheRemoving leading '/'notice istarstoring paths relative, so the archive extracts wherever you unpack it instead of forcing an overwrite of the real/etc. To get it back you reverse the verbs:tar -xzvf /backup/etc-2026-06-23.tar.gz(`-x` = extract). The archive is a single file you can copy, email, or stash off-site.ddis a different universe. It does not see files — it copies raw blocks from one device or file to another. That is exactly what you want when you need to clone an entire disk including its partition table and boot sector, which file-based tools never capture.sudo dd if=/dev/sda of=/backup/disk.img bs=4M status=progress2147483648 bytes (2.1 GB, 2.0 GiB) copied, 41 s, 52.4 MB/s
- if=
- Input File — the source. Here the whole disk /dev/sda, not a partition.
- of=
- Output File — the destination. A swapped if=/of= overwrites your source: deadly.
- bs=
- Block size per read/write. Larger (4M) is much faster than the tiny default.
- status=progress
- Print throughput as it runs, so dd isn't a silent black box.
This produces a byte-for-byte image of the entire disk — partition table, every filesystem, even unused space. That fidelity is the point: you can write the image back with if/ofreversed and get a bit-identical disk. The cost is size and rigidity — a 2 TB disk makes a ~2 TB image even if it holds 5 GB of data, becausedddoesn't know what "empty" means.Check yourself
You need a backup that, restored to a blank disk, boots on its own — capturing the partition table and boot sector. tar or dd?
rsync and the trailing slash
Use rsync for incremental and remote copies, and master the trailing-slash rule that trips everyone.
rsyncis the everyday backup workhorse because it is incremental: after the first copy, it transfers only the differences, so repeat runs are fast even over a slow link. It works locally or over SSH to a remote host. But it has one rule that catches every newcomer at least once: a trailing slash on the source changes what gets copied.Example — not runnable on your lab box
rsync -av /data/photos/ /backup/photos/sending incremental file list beach.jpg mountain.jpg sent 4.21M bytes received 57 bytes 8.42M bytes/sec
- -a
- Archive mode: recurse and preserve permissions, timestamps, symlinks, owners. The sane default.
- -v
- Verbose: list the files transferred so you can confirm what moved.
The source ends in a slash — /data/photos/— so rsync copies the contents ofphotosinto/backup/photos/. You get/backup/photos/beach.jpg. Read the trailing slash as "the contents of this directory".Example — not runnable on your lab box
rsync -av /data/photos /backup/photos/sending incremental file list photos/ photos/beach.jpg photos/mountain.jpg
Same command, but the source has no trailing slash — /data/photos. Now rsync copies the directory itself into the destination, giving you/backup/photos/photos/beach.jpg— a nestedphotos/photosyou did not want. The destination slash never matters; only the source slash changes behaviour.For a remote backup, the destination becomes
user@host:/path. rsync tunnels over SSH automatically:Example — not runnable on your lab box
rsync -avz /data/photos/ backup@192.0.2.50:/srv/backups/photos/sending incremental file list beach.jpg mountain.jpg sent 3.98M bytes received 57 bytes total size 4.21M
- -a
- Archive mode, as before — preserve everything.
- -v
- Verbose listing of transferred files.
- -z
- Compress data in transit. Worth it over a network; skip it for fast local copies.
backup@192.0.2.50:/srv/backups/photos/means userbackupon host192.0.2.50, path/srv/backups/photos/. Added `-z` compresses the stream so less crosses the wire. The trailing-slash rule still applies to the local source, exactly as before.Check yourself
rsync -av /data/photos /backup/leaves you with /backup/photos/... but you wanted the files directly under /backup/. What single character fixes it?rsync power: --delete mirrors and --link-dest snapshots
Make an exact mirror with --delete (and respect its danger), and build space-efficient snapshots with --link-dest.
Plain
rsynconly adds and updates — it never removes files from the destination. That means a file you deleted from the source lingers in the backup forever. To make the destination an exact mirror of the source, you add--delete.Example — not runnable on your lab box
rsync -av --delete /data/photos/ /backup/photos/sending incremental file list deleting old-blurry.jpg beach.jpg mountain.jpg
- --delete
- Remove files from the DESTINATION that no longer exist in the source — making an exact mirror.
Notice the deleting old-blurry.jpgline: that file was gone from the source, so--deleteremoved it from the backup too. Now/backup/photos/is a perfect copy of/data/photos/— nothing extra. That is what you want for a true mirror, and it is exactly what makes--deletedangerous.Example — not runnable on your lab box
rsync -av --delete --dry-run /data/photos/ /backup/photos/sending incremental file list deleting old-blurry.jpg beach.jpg sent 312 bytes received 21 bytes (DRY RUN)
- --dry-run
- Show exactly what WOULD happen — including deletions — without changing a single byte.
- --delete
- (Previewed here) what would be removed from the destination.
--dry-run(also-n) is your safety net: it prints everydeletingand transfer line without touching disk. If you seedeletinglines you didn't expect, stop — your source path is probably wrong. This single habit prevents the disaster in the callout above.The last power feature is `--link-dest`, which gives you snapshot backups that barely use disk. Point it at the previous backup, and any file that hasn't changed is stored as a hard link to the old copy instead of a fresh duplicate. Unchanged files cost almost nothing; only changed files use new space — yet every snapshot directory looks like a complete, standalone backup.
Example — not runnable on your lab box
rsync -av --delete --link-dest=/backup/2026-06-22 /data/ /backup/2026-06-23sending incremental file list report.txt sent 1.02K bytes received 312 bytes total size 4.21M
- --link-dest=DIR
- Compare against DIR (yesterday's backup); hard-link unchanged files instead of recopying them.
Only report.txttransferred — it was the one file that changed. Everything else in/backup/2026-06-23is a hard link to yesterday's identical file, so the new snapshot adds only the size ofreport.txt, yet it browses as a full backup of/data/. Run it daily and you get a deep history of complete snapshots for a fraction of the disk a naive copy would need.Check yourself
Which rsync option makes the destination an EXACT mirror by removing files that no longer exist in the source — and is the one to always preview with --dry-run?
Telling users: wall and shutdown
Broadcast an immediate message with wall and schedule or cancel a reboot with shutdown.
Maintenance that drops a service or reboots a box affects whoever is logged in. The professional move is to warn them first. Two tools cover this: `wall` broadcasts a message to every logged-in terminal right now, and `shutdown` schedules a reboot/poweroff for later and notifies users automatically as the time approaches.
wall "Maintenance on db01 in 10 minutes - please save your work"Broadcast message from root@db01 (pts/2) (Mon Jun 23 14:05:11 2026): Maintenance on db01 in 10 minutes - please save your work
Every user with an open terminal sees this immediately, prefixed with who sent it and when. wall("write all") is for now — it does not schedule anything. Use it for ad-hoc heads-ups: "restarting nginx," "don't run big jobs for 5 minutes."When you need to actually reboot,
shutdowndoes the warning and the action. You give it a time — a clock time like22:00, a delay like+15(fifteen minutes), ornow— and it both schedules the event and nags logged-in users as it nears.sudo shutdown -r +15 "Rebooting for kernel update at 22:00"Shutdown scheduled for Mon 2026-06-23 22:00:00 UTC, use 'shutdown -c' to cancel.
- -r
- Reboot after shutting down (rather than -h to halt/power off).
- +15
- The TIME: 15 minutes from now. Could be a clock time like 22:00, or 'now'.
This schedules a reboot in 15 minutes and starts warning logged-in users automatically — the message you supplied is shown to them. The output even tells you the escape hatch: `shutdown -c`. The key difference from wall:shutdownperforms the action at the appointed time, whereaswallonly talks.sudo shutdown -c "Update postponed - all clear"Broadcast message from root@db01 (Mon Jun 23 21:48:02 2026): Update postponed - all clear
- -c
- Cancel a pending scheduled shutdown/reboot. Broadcasts your optional all-clear message too.
Plans change. `shutdown -c` cancels a pending shutdown before it fires and broadcasts your all-clear so users know the threat has passed. If you scheduled with +15and the maintenance window slips, this is how you call it off — there's no half-rebooted state to clean up.Check yourself
You ran
shutdown -r +30but the maintenance is cancelled. What command stops the pending reboot?Login banners: motd vs issue
Place the right banner in the right file — /etc/motd after login, /etc/issue and /etc/issue.net before login.
Three files control the text users see around login, and the entire trick is before vs after login.
- `/etc/motd` — the "message of the day", shown after a successful login. The user is already authenticated. Good for welcome notes, maintenance windows, or pointers to docs.
- `/etc/issue` — shown before login at the local console prompt. The user hasn't authenticated yet.
- `/etc/issue.net` — shown before login for network logins (e.g. Telnet, and SSH when configured to display it).
The analogy: `/etc/issue` is the sign on the front door (everyone sees it before entering); `/etc/motd` is the note on the kitchen fridge (only people already inside the house read it).
Example — not runnable on your lab box
cat /etc/motdWelcome to db01. Authorized use only. Scheduled maintenance: Sunday 02:00-03:00 UTC. Questions? ops@example.com
This appears after the user logs in successfully — it's the first thing they read on the shell. Because they're already authenticated, motdis the place for operational notes: maintenance windows, contact info, the day's reminders.cat /etc/issueDebian GNU/Linux 12 \n \l
This shows at the console login prompt, before anyone authenticates. The escape sequences are expanded live by getty:\nbecomes the hostname and\lthe terminal line. Because it's seen before login,/etc/issueis where authorized-use warning banners belong — there's no point warning someone after they're already in.Check yourself
Which file should hold a legal 'authorized use only' warning so the user sees it BEFORE they log in at the console?
Try it in your live terminal
Do it, don't just read it — these read-only commands run on the real sandbox to your right.
You have a real root shell. Every command below is read-only or a dry run — nothing is created, copied, or deleted. Run them in order to see the tools and banners on your actual system.
rsync --version | head -1Confirm rsync is installed and check its version — older builds differ slightly on flags. Read-only: it only prints the version line. Example — not runnable on your lab box
rsync -av --delete --dry-run /etc/ /tmp/etc-mirror/A safe preview of a mirror: --dry-run means NOTHING is written or deleted. Watch the listed files and any deletinglines — this is exactly the habit that prevents a --delete disaster.cat /etc/motd 2>/dev/nullSee your after-login message of the day. The 2>/dev/nullquietly swallows the error if the file doesn't exist on this box.cat /etc/issueSee your before-login console banner, escape sequences and all. Contrast it with /etc/motd above: this one greets users BEFORE they authenticate.
- Match the tool to the job:
tarfor portable archives,rsyncfor incremental/remote mirrors,ddfor raw block images,dump/restorefor leveled ext backups. - rsync's trailing slash on the source decides contents-vs-directory;
--deletemakes an exact mirror (and can wipe a backup if the source path is wrong — always--dry-runfirst);--link-destgives cheap hard-link snapshots. walltalks now;shutdown -r TIMEschedules a reboot and warns users;shutdown -ccancels a pending one.- Banners hinge on before-vs-after login:
/etc/motdshows after login;/etc/issue(console) and/etc/issue.net(network) show before — so legal warnings go inissue, notmotd.
| Tool / command | Best for | Watch for |
|---|---|---|
tar -czf | Portable, compressible archive of files | Stores files only — misses boot sector / partition table |
rsync -av | Incremental local or remote (SSH) copies | Trailing slash on source = contents vs directory |
rsync --delete | Exact mirror of source | Wrong/empty source deletes the backup — --dry-run first |
rsync --link-dest | Space-efficient hard-link snapshots | Point it at the previous backup directory |
dd | Raw block image / full-disk clone | if/of swap overwrites the source; image is full disk size |
dump/restore | Leveled (incremental) ext2/3/4 backups | Filesystem-specific — ext family only |
wall | Immediate broadcast to logged-in users | Talks now; performs no action |
shutdown -r TIME / -c | Schedule a reboot (and notify) / cancel it | TIME is +mins, a clock time, or now |
/etc/motd | Message shown AFTER login | Too late for legal warnings |
/etc/issue / issue.net | Banner BEFORE login (console / network) | SSH needs Banner set to show issue.net |
