Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Complete Linux System Backup and Restoration Guide

Tech Nov 23 1

Linux distributions like Ubuntu offer a more streamlined approach. Unlike Windows, Linux doesn't restrict root access to system files, allowing comprehensive backups using standard utilities. Commercial backup tools designed for Windows often provide poor support for Linux filesystems, with limited compatibility for modern filesystem versions.

Creating System Archives

Creating a complete system backup in Linux is straightforward using the tar utility. First, gain root privileges:

$ sudo su

Navigate to the filesystem root (or your preferred backup target directory):

# cd /

Execute the following command to create a compressed archive:

# tar cvpzf system_archive.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/system_archive.tar.gz --exclude=/mnt --exclude=/sys /

Breaking down this command:

  • tar: The archiving utility
  • cvpzf: Options for creating an archive, preserving permissions, and using gzip compression
  • system_archive.tar.gz: The output filename for your backup
  • --exclude flags: Directories to omit from the backup
  • /: The source directory (entire filesystem)

The excluded directories serve specific purposes:

  • /proc and /sys: Virtual filesystems containing runtime system information
  • /lost+found: Contains recovered filesystem fragments
  • /system_archive.tar.gz: Prevents the archive file from including itself
  • /mnt: Avoids backing up mounted filesystems

Verify no external media is mounted in /media before proceeding. The backup process may require considerable time depending on your system size.

For higher compression rates (though slower processing), consider using bzip2:

# tar cvpjf system_archive.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/system_archive.tar.bz2 --exclude=/mnt --exclude=/sys /

System Restoration Process

Exercise extreme caution during restoration! Incorrrect execution can result in data loss.

Continue with root privileges and ensure your archive file is in the root directory:

Linux allows restoration from a running system without requiring boot media. If your system won't boot, use a Live CD environment.

Execute the restoration command:

# tar xvpfz system_archive.tar.gz -C /

For bzip2-compressed archives:

# tar xvpfj system_archive.tar.bz2 -C /

This command overwrites all files with the archived versions. Verify the command carefully before execution.

After restoration completes, recreate the excluded directories:

# mkdir proc
# mkdir lost+found
# mkdir mnt
# mkdir sys
# mkdir media

Set appropriate permissions where necessary:

# chmod 555 proc
# chmod 700 lost+found

Upon rebooting, your system should return to its state at the time of backup creation.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.