System Maintenance
System Maintenance covers building and installing software from source, designing backups that restore correctly, rotating logs, and notifying users about maintenance.
Source, backup and logs
- A typical source build is
./configure --prefix=/usr/local,make,make install. Use--helpto see options andDESTDIRto stage files for packaging instead of writing directly to the live root. tar -czf,rsync -aAX,dd, andcpioserve different backup needs.rsyncpreserves ownership, ACLs and xattrs with-aAX; trailing slashes change whether the source directory itself is copied.- Test restores, not only backups. A backup on the same disk is not protection against disk failure.
logrotatereads/etc/logrotate.confand/etc/logrotate.d/; test withlogrotate -dbefore relying on a new rule.- Notify users with
wall,/etc/motd, or a scheduledshutdown +10 'message'.
Worked example
Back up /srv nightly to /backup/srv while preserving metadata. Run rsync -aAX --delete /srv/ /backup/srv/ after a --dry-run. Reasoning: -a recurses and preserves times, symlinks and permissions; -A preserves ACLs; -X preserves xattrs. The trailing slash on /srv/ copies its contents into /backup/srv/; without it, the result would be /backup/srv/srv/. --delete removes files at the destination that no longer exist at the source, so dry-run first.
Traps
- Running
make installwithout a prefix and overwriting distribution files. - Misreading rsync's trailing-slash behavior.
- Rotating logs with wrong ownership or permissions.
- Never testing a restore.