Linux

How to Create a Full System Backup in Linux: A Detailed Guide

This guide will help you set up a full system backup in Linux, including all files and settings, using tools like rsync and tar.

Updated at February 16, 2026
15-30 minutes
Medium
FixPedia Team
Применимо к:Ubuntu 20.04+Debian 10+Fedora 35+CentOS 7+

Introduction / Why This Is Needed

Backing up a Linux system is not just a good practice but a necessity for protection against hardware failures, update errors, or malicious attacks. A full backup allows you to restore the entire operating system, configurations, and user data to its original state. In this guide, you will learn how to create reliable system copies using standard Linux tools such as rsync and tar. Upon completion, you will have a ready-to-use backup that can be stored on external media or network storage and used for recovery when needed.

Requirements / Preparation

Before you begin, ensure you have:

  • Target media: An external hard drive, USB drive, or network storage (NFS, Samba) with capacity exceeding the used space on your system. A 20-30% buffer is recommended for backup rotation.
  • Administrator privileges: root or sudo access is required to access system files and mount disks.
  • Basic terminal skills: Ability to execute commands and edit files.
  • Installed utilities: rsync, tar, cron (usually pre-installed on most distributions). dd is also typically available.
  • Stable connection: If using network storage, ensure a reliable connection.

Step 1: Preparing the Target Media

First, connect and prepare the disk for backup storage.

  1. Identify your disk device using the lsblk or sudo fdisk -l command. For example, an external disk may appear as /dev/sdb1.
  2. If the disk is new or you wish to reformat it, create a filesystem. For most cases, ext4 is suitable:
    sudo mkfs.ext4 /dev/sdX1
    
    Replace sdX1 with your actual device.
  3. Create a mount point, for example, /mnt/backup:
    sudo mkdir -p /mnt/backup
    
  4. Mount the disk:
    sudo mount /dev/sdX1 /mnt/backup
    
  5. For automatic mounting after reboot, add an entry to /etc/fstab. Open the file:
    sudo nano /etc/fstab
    
    Add a line (replace UUID or device):
    UUID=your-uuid /mnt/backup ext4 defaults 0 2
    
    You can find the UUID via blkid.
  6. Verify the disk is mounted and has sufficient space:
    df -h /mnt/backup
    

Step 2: Choosing a Backup Tool

For a full system backup, there are several tools, each with its own features:

  • rsync: Ideal for incremental copies. It copies only changed files, saving time and space. Supports preservation of permissions, owners, and attributes. Well-suited for regular backups.
  • tar: Creates a single compressed archive. Simple to use but does not support incrementality without additional scripts. Suitable for one-off full backups.
  • dd: Copies a full block device image, including the bootloader and unallocated space. Requires significant space and time, and restoration is more complex. Use with caution, only for full disk cloning.

In this guide, we will focus on rsync and tar as the most practical for most users. dd is only covered for specific scenarios.

Step 3: Creating a Full System Backup

Option A: Using rsync

rsync allows you to create a full system copy while preserving all attributes, excluding temporary and virtual filesystems.

Run the command as root:

sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt/backup

Options:

  • -a: Archive mode (preserves permissions, timestamps, symbolic links).
  • -A: Preserves ACLs (access control lists).
  • -X: Preserves extended attributes (xattr).
  • -v: Verbose output.
  • --exclude: Excludes directories that should not be copied (they are dynamically generated by the system or are mount points).

The process may take time depending on data volume. For future incremental backups, simply repeat the same command—rsync will copy only the changes.

Option B: Using tar

tar creates a compressed archive of the entire system. This is a good option for a one-time full backup.

sudo tar -cvpzf /mnt/backup/full_backup_$(date +%Y-%m-%d).tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys /

Options:

  • -c: Create archive.
  • -v: Verbose output.
  • -p: Preserve permissions.
  • -z: Compress with gzip.
  • -f: Specify filename.
  • --exclude: Exclude unnecessary directories.

The archive will be saved with the date in the filename, e.g., full_backup_2026-02-16.tar.gz. Note that creating a large archive may require significant time and temporary disk space.

Option C: Using dd (for a full disk image)

⚠️ Caution: dd copies the disk bit-by-bit, including all partitions and the bootloader. Ensure the target disk is large enough and you have specified the correct devices. An error can lead to data loss.

sudo dd if=/dev/sda of=/mnt/backup/system_image.dd bs=64K conv=noerror,sync
  • if: Input device (source disk, e.g., /dev/sda).
  • of: Output file on the target media.
  • bs: Block size for speed.
  • conv=noerror,sync: Continue on read errors, pad with zeros.

This method creates a full image but does not allow easy extraction of individual files without mounting. Restoration requires writing the image back to a disk.

Step 4: Verifying Backup Integrity

After copying completes, always verify the backup is correct:

  1. Check free space on the target disk:
    df -h /mnt/backup
    

    Ensure used space matches expectations.
  2. For rsync: Run the command again. If nothing changed, the output will show all files are up-to-date.
    sudo rsync -aAXn --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt/backup
    

    The -n (dry-run) option will show which files would be copied. If the output is empty—the backup is synchronized.
  3. For tar: Check archive contents:
    tar -tvzf /mnt/backup/full_backup_*.tar.gz | head -20
    

    This lists the first 20 files. You can also try extracting a single file to a test directory:
    sudo tar -xzvf /mnt/backup/full_backup_*.tar.gz /etc/hosts -C /tmp/
    

    Ensure the file restored correctly.
  4. For dd: Check the image checksum (if created from the source disk):
    sudo dd if=/dev/sda bs=64K | md5sum
    sudo dd if=/mnt/backup/system_image.dd bs=64K | md5sum
    

    The sums should match, but this is slow for large disks. Alternatively, check the file size:
    ls -lh /mnt/backup/system_image.dd
    

Step 5: Setting Up Automation (Optional)

To avoid forgetting regular backups, configure automatic execution via cron.

  1. Open root's crontab:
    sudo crontab -e
    
  2. Add a line for a daily incremental backup at 2:00 AM:
    0 2 * * * rsync -aAX --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt/backup
    
    For a monthly full backup using tar with file rotation, use a script like:
    #!/bin/bash
    BACKUP_DIR="/mnt/backup"
    DATE=$(date +%Y-%m-%d)
    tar -cvpzf $BACKUP_DIR/full_backup_$DATE.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys /
    find $BACKUP_DIR -name "full_backup_*.tar.gz" -mtime +30 -delete  # delete backups older than 30 days
    
    Save it as /usr/local/bin/backup_system.sh, give it execute permissions chmod +x, and add to cron:
    0 3 1 * * /usr/local/bin/backup_system.sh
    
    This will run a full backup on the 1st of every month at 3:00.

Verifying the Result

After setup, ensure the backup is working correctly:

  • For manual backups: Check for files on the target disk. Ensure key directories (/etc, /home, /var) are copied.
  • For automated backups: Check cron logs:
    sudo grep CRON /var/log/syslog
    
    Or look for new backup files in /mnt/backup.
  • Test restoration: Try restoring an important file from the backup. For example, with rsync:
    sudo rsync -av /mnt/backup/etc/hosts /tmp/
    
    Compare the original and restored file.
  • For tar: Extract a test file as in Step 4.

If all files are present and restoration works, the backup is set up successfully.

Potential Issues

When creating a Linux system backup, the following difficulties may arise:

  • Insufficient space on the target disk:

    💡 Tip: Always check free space before starting with df -h. A full system backup requires space equal to the amount of used data. Note that incremental backups with rsync take up less space, but initial copies can be large.

  • Access errors or "Permission denied": Run commands with sudo. Ensure the target disk is mounted with write permissions for root. Check if SELinux or AppArmor might be blocking access.
  • Incomplete backup or missing files: Ensure only unnecessary directories (/proc, /sys, /tmp, etc.) are excluded. Verify you haven't accidentally excluded something important. For rsync, use the -a option to preserve everything.
  • Data consistency while the system is running: If the system is active, some files (e.g., databases) may change during copying, leading to an inconsistent backup.

    ⚠️ Important: For critical data, stop services (e.g., sudo systemctl stop mysql) before backup or use tools supporting snapshots (LVM, Btrfs, ZFS). For example, with LVM:

    sudo lvcreate --snapshot --name backup_snap --size 1G /dev/vg0/root
    sudo mount /dev/vg0/backup_snap /mnt/snap
    sudo rsync -aAX /mnt/snap/ /mnt/backup/
    sudo umount /mnt/snap
    sudo lvremove -f /dev/vg0/backup_snap
    
  • Restoration issues on different hardware: A full system backup may not boot on different hardware due to driver differences (especially proprietary ones) or bootloader configuration.

    💡 Tip: For migration to different hardware, use tools like Clonezilla or create a backup focused on hardware independence (e.g., only /home and /etc). Restoring to a new system may require reinstalling the bootloader (grub-install) and configuring drivers.

  • Long execution time: Backing up a large system can take hours. Use rsync for subsequent copies—it will process only changes. Also consider real-time compression (e.g., with pv and gzip), but this increases CPU load.
  • Errors with network storage: Mounting NFS or Samba can cause timeouts. Ensure network stability and configure mount options (e.g., hard,intr for NFS). For large backups, use rsync with --partial to resume interrupted transfers.

F.A.Q.

Can I back up the system without stopping services?
How often should I back up the system?
Will there be enough space on the external drive for the backup?
Can I restore the system to different hardware?

Hints

Preparing the target media
Choosing a backup tool
Creating a full system backup
Verifying backup integrity
Setting up automation (optional)
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community