Open In App

A Versatile System Backup Script for Linux

Last Updated : 09 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

System Tar and Restore is a flexible system and it has two bash scripts one is the main script star.sh and the other is the GUI wrapper star-gui.sh. It has three modes accessible in the System Tar and Restores system namely: Backup, Restore, and Transfer.

  • Backup: With this, we can take the tar backup archive of our system.
  • Restore: Restore mode utilizes the archive created by the backup mode to extract it into expected partitions.
  • Transfer: This mode uses rsyn to transfer our system to expected partitions.

Features:

  • It enables complete or Partial System Backup.
  • The BIOS-based system is restored to UEFI and conversely.
  • Restore/Transfer equivalent or different disk or the partition layout.
  • Restore/Transfer the tar backup archive to an external drive such as SSD, SD, USB, etc.
  • A virtual machine is arranged to back backup and restore the system.

Requirements:

  • For GUI we use gtkdialog 0.8.3 
  • To download the substitute archives we use wget- for retrieving files from (WWW )World Wide Web.
  • As tar compressed the collection of files into an archive we use tar 1.27 and for the acls and xattrs support. 
  • For the Transfer mode, we utilize the Rsyn(Remote Sync)- for copying and organizing files and directories remotely.
  • For GPT and Syslinux we use gptfdisk/gdisk.
  • For encryption purposes, we use openssl/gpg.

Installation of System Tar and Restore tool:

To set up the System Tar and Restore program, essential packages need to be installed.

Syntax:

$ sudo apt install git tar rsync wget gptfdisk openssl  [For Debian/Ubuntu users]
# yum install git tar rsync wget gptfdisk openssl       [For CentOS/RHEL users]
# dnf install git tar rsync wget gptfdisk openssl       [For Fedora users]

By using these commands the required packages can be installed after installing the packages we need to download these packages by cloning the System tar and Restore repository into the local system and executing their programs with the privileges of the root user, in other cases use sudo command.

$ git clone https://github.com/tritonas00/system-tar-and-restore.git
$ cd system-tar-and-restore/
$ ls

Output:

Installing System Tar and Restore

Installing System Tar and Restore

System Backup:

The initial step is to create or select a directory to store the system backup files. then execute the commands mentioned below to create a system backup file in the /backups directory, then use the 

xz utility – this utility supports the compression of data this utility can be used for both compression and decompression of a file in accordance with the specified operation mode.

Flags used are:

  • -d – Describes the destination directory, in which the backup files will be stored.
  • -u – Permits for reading additional tar or the rsyn operations.
  • -i  – Describes the operation mode, where zero (0) refers to the backup mode.
  • -c – Specifies the compression utility.

Syntax:

$ sudo ./star.sh -i 0 -d /backups -c xz -u "--warning=none"

To eliminate the /home in the backup, then add the -H flag and use gzip utility- to compress and reduce the size of the files as shown below.

$ sudo ./star.sh -i 0 -d /backups -c gzip -H -u "--warning=none"

Output:

Starts to take system Backup

Starts to take system Backup

Restore the System Backup:

We use System Restore to extract the archived backup files and we can use the below flags to get details of the status.

Flags used are:

  • -G – Describes the grub partition.
  • -r  – Specifies targeted root (/) partition.
  • -i – Describes operation mode one (1) which refers to restore mode.
  • -f – Defines the path of the backup file.

Syntax:

$ sudo ./star.sh -i 1 -r /dev/sdb1 -G /dev/sdb -f /backups/backup.tar.xz

There is another example where we can use transfer mode (2) appending with the -b flag which set up the boot partition.

$ sudo ./star.sh -i 2 -r /dev/sdb2 -b /dev/sdb1 -G /dev/sdb

As well, if the system is mounted /usr and /var in different partitions, by specifying the -t flag to switch.

$ sudo ./star.sh -i 2 -r /dev/sdb2 -b /dev/sdb1 -t "/var=/dev/sdb4 /usr=/dev/sdb3" -G /dev/sdb

Using GUI (graphical user interface):

By using GUI wrapper star-gui.sh you can utilize the GUI. For this, you need gtkdialog- which will lead you to the graphical interfaces in Linux.

Conclusion:

System Tar and Restore are flexible, powerful, and feature-rich backup scripts that effectively back up the files in the local system. By using the System Tar and Restore we take backup and also it assists to restore and transfer to the current or a different disk partition.  


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads