Backup and Restore Procedures. This concept solves one of the most terrifying problems in IT: losing irreplaceable data. For an LPIC-2 candidate, understanding how to reliably back up and restore Linux systems is a core skill that separates a hobbyist from a professional systems administrator.
Jump to a section
A simple way to picture Backup and Restore Procedures
Three times a week, you cook a big meal. You have a fire extinguisher mounted on the wall next to the stove. You've never used it, but you check the pressure gauge every month. One Sunday, while frying chicken, the oil catches fire. You grab the extinguisher, pull the pin, and put out the fire in seconds. The extinguisher is your backup. The fire is data loss. The act of grabbing it is the restore procedure.
Now imagine you move to a new apartment. You take the fire extinguisher with you. But you forgot to check if it's still full — you just assumed it had enough pressure. When the new stove flares up, the extinguisher sputters and dies. That's a failed backup: you saved the file, but the media was corrupt or the data was incomplete. A backup isn't real until you have tested restoring from it.
The same logic applies to your LPIC-2 exam. You will learn to schedule automatic backups (like mounting the extinguisher), verify their integrity (checking the pressure gauge), and restore data (pulling the pin). Without a tested restore procedure, your backup is just a false sense of safety.
Let's start with the absolute basics. A backup is a copy of data that you keep separate from the original. The restore is the process of putting that data back where it belongs after the original is lost or damaged. In Linux, everything is a file: documents, databases, configuration settings, even the operating system itself. So backing up Linux means copying those files to another location.
Why do we need backups? Hard drives fail. People delete things by accident. Ransomware encrypts files. A building catches fire. Backups are insurance. The cost of storing backup data is tiny compared to the cost of losing business data, customer records, or an entire server.
There are different types of backups. Let's list the three main categories:
Full backup: copies every single file you select. It's thorough but takes a lot of time and storage space.
Incremental backup: copies only the files that changed since the last backup (whether that was a full or another incremental). It is fast but restoring requires the full backup plus every incremental backup in order.
Differential backup: copies files that changed since the last full backup. It is slower than incremental but faster to restore, because you only need the full backup and the latest differential.
Now, how do you actually perform backups on Linux? The classic tools are tar, cpio, dd, and rsync. tar stands for 'tape archive' — historically used to write data to magnetic tape drives. Today we use tar to bundle a group of files into a single archive file (like a .tar file), often compressed with gzip or bzip2. cpio is an older tool for copying files in and out of archives. dd is a low-level tool that copies raw data, bit by bit, from one device to another — useful for cloning entire hard drives. rsync is a modern tool that synchronises files between two locations, only transferring the parts that changed, which is perfect for incremental backups over a network.
Where do you store backups? Options include local hard drives, external USB drives, network-attached storage (NAS), tape drives, and cloud storage. Each has trade-offs in speed, cost, and safety. A best practice is the 3-2-1 rule: keep three copies of your data, on two different types of media, with one copy stored off-site.
The restore process is the other half. You must be able to retrieve your data quickly. This is where backup verification comes in. A backup that you cannot read is worthless. Tools like md5sum or sha256sum generate checksums — digital fingerprints of your backup files. After creating a backup, you compute the checksum and store it separately. During a restore, you recompute the checksum and compare it. If they match, the backup is intact.
Finally, automation is critical. No one remembers to run backups manually at midnight. In Linux, you use cron to schedule backup jobs. Cron is a time-based job scheduler — you write a script that runs tar or rsync, and cron executes it at the specified time. The script should log its output to a file so you can check for errors. A typical cron entry looks like: 0 2 * * * /usr/local/bin/backup-script.sh — this runs the backup script every day at 2 AM.
The key takeaway: backups are not optional. They are the safety net that lets you sleep at night knowing your data can survive a disaster.
Assess what data needs backing up
Identify critical files: databases, configuration files, user home directories, and application data. Not everything needs daily backup. Prioritise based on business impact.
Choose a backup tool
Select the right command for the job: tar for archiving files, rsync for synchronising, dd for disk cloning, or cpio for tape backups. Each has strengths and weaknesses.
Create the backup
Run the backup command: for example, 'tar -czf backup.tar.gz /var/www' creates a compressed archive of the web directory. Redirect output to a log file for auditing.
Verify the backup
Generate a checksum of the backup file using sha256sum. Store this checksum in a separate location. Also extract a sample file to confirm the archive is readable.
Store the backup securely
Copy the backup file to at least two different locations: one local (external drive) and one remote (cloud storage or another server). Use rsync or scp for remote transfers.
Schedule regular backups
Configure a cron job to run the backup script automatically. Test the cron job by checking the log the next day. Adjust timing to fit the backup window.
Practise the restore procedure
At least once per quarter, perform a full restore to a test environment. Document each step and timing. This ensures you can recover quickly during a real disaster.
Imagine you are a junior systems administrator for a mid-sized e-commerce company. The company runs its website on a Linux server. Customer orders, product inventory, and payment logs are stored in a PostgreSQL database. One Tuesday morning, a developer accidentally runs a script that deletes the entire 'orders' table. The CEO wants the data back immediately.
Here is what you do step by step:
First, you assess the situation. You check if you have a backup. Let's say your team uses a nightly cron job that runs pg_dump (a PostgreSQL backup tool) to create a compressed SQL dump file, stored on a separate network drive. You locate the most recent backup file from last night, named 'orders_backup_2025-03-17.sql.gz'.
Second, you verify the backup file is not corrupted. You use the sha256sum command to compare the backup file's checksum against the one logged in your backup log. The checksums match.
Third, you restore the database. You uncompress the file with gunzip and use psql (the PostgreSQL command-line tool) to import the SQL dump into a temporary database called 'orders_recovery'. This prevents accidentally overwriting any data that may still be in the live database.
Fourth, you confirm the restored data looks correct. You run a SELECT query to count the rows in the 'orders' table. It shows exactly the number you expected. You then inform the developer to point the application to the restored database.
Finally, you document the incident. You write a post-mortem explaining what happened, how you restored the data, and what process changes could prevent a recurrence — such as adding a confirm step before destructive SQL commands.
Tools you would use in this scenario: - pg_dump for database backups - sha256sum for integrity checking - cron for scheduling - rsync to copy backup files to an off-site location - tar to bundle log files - systemd timers as an alternative to cron
The real-world lesson: a tested restore procedure is more valuable than any backup. You must practise the restore process at least quarterly, not just on the day of the crisis.
The LPIC-2 exam objective 202.1 focuses on your ability to understand and implement backup and restore strategies using Linux command-line tools. You will not be asked about graphical backup tools. The exam is strictly about command-line proficiency.
Here are the exact concepts they love to test:
Differences between full, incremental, and differential backups. You must know which type of backup is fastest to create, which is fastest to restore, and which uses the least storage space. They will pose a scenario: 'Your backup window is only two hours and you have 500 GB of data changing daily. Which backup type do you choose?'
The tar command: know all its common options. Specifically: -c (create), -x (extract), -f (specify archive file), -z (compress with gzip), -j (compress with bzip2), -v (verbose). You will be asked to construct a command to create a compressed archive of a directory.
The cpio command: how to create a cpio archive and extract it. Expect a question about using cpio with find to back up selected files.
The dd command: its syntax for cloning a disk or partition. Questions often involve the if= (input file) and of= (output file) parameters, and bs= (block size) to improve speed. Trap: dd can overwrite a disk with no warning.
The rsync command: know its key options like -a (archive mode which preserves permissions, timestamps, etc.), -v (verbose), -z (compress during transfer), and --delete (remove files on the destination that no longer exist on the source). They will test your understanding of rsync's ability to resume interrupted transfers.
Backup media: you need to know about tape drives (/dev/st0, /dev/nst0) and how to use mt (magnetic tape control) to rewind or eject tapes.
Integrity checks: they will ask about md5sum and sha256sum to verify backup integrity.
Scheduling: cron syntax is essential. Know the five fields (minute, hour, day of month, month, day of week) and how to schedule a backup script.
Common traps:
Confusing incremental with differential. They will deliberately ask: 'You need to restore from a full backup taken on Sunday and differential backups taken on Monday and Tuesday. Which backups do you need?' The correct answer is only Sunday's full and Tuesday's differential. The Monday differential is not needed because the Tuesday one contains all changes since Sunday.
Forgetting that cpio uses a different syntax to tar. cpio expects a list of files on standard input.
Thinking dd is safe to run without double-checking the output device. They might give a command with of=/dev/sda (wiping the system disk) and ask if it's safe.
To pass, memorise the key command options and practise constructing backup commands on the command line. The exam is hands-on with multiple-choice scenarios that require precise recall.
A backup is only as good as your last successful restore test.
The 3-2-1 rule means three copies of your data, on two different media, with one off-site.
Full backups are the foundation; incremental backups save space but slow down restores.
Differential backups grow larger each day but restore faster than incremental backups.
Always verify backup integrity using checksums like sha256sum.
Cron scheduling automates backups; systemd timers are a modern alternative.
The dd command can destroy data instantly if you specify the wrong output device.
These come up on the exam all the time. Here's how to tell them apart.
Full Backup
Copies all selected files each time
Requires the most storage space
Fastest to restore (only one file needed)
Incremental Backup
Copies only files changed since last backup
Uses the least storage space
Slowest to restore (must apply all incrementals in order)
Differential Backup
Copies files changed since last full backup
Restore requires only full backup plus latest differential
Backup size grows each day until next full backup
Incremental Backup
Copies files changed since last backup of any type
Restore requires full backup plus all incrementals
Backup size stays small but restore is complex
tar
Creates a single archive file
Best for full backups and long-term storage
Does not support incremental transfers natively
rsync
Synchronises files between directories or machines
Ideal for incremental backups over a network
Can resume interrupted transfers
dd
Copies raw data bit by bit
Used for cloning entire disks or partitions
Does not check file system consistency
cpio
Copies files based on a list from standard input
Often used with find for selective backups
Preserves file metadata and works well with tapes
Mistake
A backup is complete if you copy all the files to an external drive once.
Correct
A backup strategy must be continuous and verified. One copy is not enough; you need multiple versions over time, plus regular restore tests.
Beginners think 'backup' is a one-time task. They don't realise data changes constantly and that a single copy can fail silently.
Mistake
Using dd to back up a running system is fine because it copies everything.
Correct
dd does not check file system consistency; if files change during the copy, the backup can be corrupted. You should unmount the file system or use tools like rsync or tar that handle open files better.
dd looks simple and powerful, so beginners assume it's the best tool. They don't understand file system consistency.
Mistake
Incremental backups are always better because they are smaller.
Correct
Incremental backups use less storage but restore is slower and more complex. For quick recovery, differential or full backups are often better.
People focus on storage savings without thinking about the restore time. LPIC-2 tests trade-offs.
Mistake
You don't need to test restores if you use rsync because it verifies files during transfer.
Correct
rsync verifies during transfer but does not guarantee the destination media will not fail later. You must test restore from the backup media itself.
Beginners over-rely on tool features and ignore the physical risks of media failure.
Mistake
cpio is obsolete and you won't see it on the exam.
Correct
LPIC-2 specifically tests cpio because older systems and tape backup scripts still use it. You must know its syntax.
Learners ignore older tools and assume only modern ones matter. The exam covers legacy tools still in use.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
An incremental backup copies only files changed since the last backup of any type. A differential backup copies files changed since the last full backup. Restoring from incremental requires the full backup plus all incrementals in order; restoring from differential requires only the full backup and the latest differential.
Edit the crontab file with 'crontab -e' and add a line like '0 2 * * * /path/to/backup-script.sh', which runs the script daily at 2 AM. The five fields represent minute, hour, day of month, month, and day of week.
The tar -czf command creates a compressed archive. -c creates the archive, -z compresses it with gzip, and -f specifies the output filename. Example: tar -czf backup.tar.gz /home/user.
Use sha256sum or md5sum to compute a checksum of the backup file immediately after creation. Store that checksum separately. To verify later, recompute the checksum and compare it to the stored value. If they match, the backup is intact.
The 3-2-1 rule is a best practice: keep three copies of your data, on two different types of storage media, with at least one copy stored off-site (for example, a local external drive and a cloud storage service).
No. dd copies raw data without checking file system consistency. If files change during the copy, the result may be corrupt. Always unmount the file system or use a tool like rsync that handles live data better.
You've finished Backup and Restore Procedures. Continue through the LPIC-2 study guide to build a complete picture of the exam.
Done with this chapter?