Kahibaro
Discord Login Register

Backup and Restore

Why Backup and Restore Matters

Data loss on Linux systems can come from hardware failure, user mistakes (rm -rf in the wrong place), software bugs, or malware. Backup and restore is about having:

For administration work, backups are not optional: they’re part of normal operations and planning, not just emergencies.

Key questions you should be able to answer for any system:

These questions drive your backup strategy and choice of tools (covered in later subsections).

What Needs to Be Backed Up on a Linux System

On a typical Linux system, not everything needs backing up. Many files can be reinstalled from packages. Focus on:

Critical data

System and service configuration

Optional but useful

What usually does *not* need backup

On most systems, you can skip:

You can exclude these from backups to save space and time.

Types of Backups

Backups are usually described by how much data they copy each time:

Full backups

Incremental backups

Differential backups

Many real-world tools internally manage these differences, but the concepts still apply: you trade backup size/speed against restore complexity.

Backup Destinations

Where you send your backups matters as much as how you create them.

Common destinations:

Basic rule: DO NOT keep the only backup on the same physical disk as the data. Disk failure will take both.

Basic Backup Strategies and Policies

A backup strategy defines when and how you run backups and what you keep. Even simple environments should have a written plan.

The 3–2–1 rule

A widely used guideline:

This rule helps protect you against disk failure, local disasters, and mistakes.

Retention policies

Retention is about how long you keep each backup before deleting it.

Examples:

Even a small system benefits from a simple policy, so backup storage doesn’t grow without limit.

Scheduling

Backups should run automatically:

Backup Consistency and Online Data

Backing up files that are actively being written can create inconsistent backups.

Ways to handle this:

The correct approach depends on the service (database, VM, application), but the principle is: aim for data that represents a consistent point in time.

Testing Restores

A backup is only useful if you know you can restore it.

Basic practices:

Testing reveals missing files, bad assumptions, or broken scripts before a real emergency.

Encryption and Access Control

Backups often contain everything: user data, secrets, configs, database dumps. They must be protected.

Encryption

Permissions and access

Disaster Recovery vs. Everyday Restores

Backups serve two main scenarios:

Everyday restore

Characteristics:

Disaster recovery

Characteristics:

Your planning should consider both. Everyday restores are common; disasters are rare but more severe.

Versioning and Snapshots vs Traditional Backups

Backups usually keep archived copies in a separate location. Some systems also use:

For robust protection, snapshots complement backups but do not replace them.

Planning a Simple Backup and Restore Workflow

For a beginner-friendly Linux system, an example approach:

  1. Decide what to back up:
    • /home, /etc, important app data in /var or /srv, and custom scripts in /usr/local or /opt.
  2. Decide where:
    • External disk and/or remote server.
  3. Decide how often:
    • Daily incremental, weekly full.
  4. Implement with basic tools:
    • Use rsync or tar scripts (detailed later in this section).
    • Schedule with cron or systemd timers.
  5. Secure it:
    • Use restricted permissions and, if needed, encryption.
  6. Document and test:
    • Write restore steps.
    • Do a test restore at least monthly.

The later subsections in this part (rsync, tar archives, snapshot systems, automation) provide concrete commands and examples to fill in each step.

Views: 28

Comments

Please login to add a comment.

Don't have an account? Register now!