- About
- Distribution Packages
- Requirements
- Things you can do
- Backup Mode
- Restore/Transfer Mode
- Notes
- Examples using arguments
System tar & restore contains two bash scripts, the main program star.sh and a gui wrapper star-gui.sh.
Three modes are available: Backup, Restore and Transfer.
Supported distributions: Arch, Debian/Ubuntu, Fedora, openSUSE, Gentoo, Mandriva/Mageia
Archlinux
See the wiki page.
Gentoo
The package is provided by the gentoo-el
overlay. You can install it with the following commands as root. (you need to have layman
installed and configured)
layman -a gentoo-el
emerge app-backup/system-tar-and-restore
- gtkdialog 0.8.3 or later (for the gui)
- tar 1.27 or later (acls and xattrs support)
- rsync (for Transfer Mode)
- wget (for downloading backup archives)
- gptfdisk/gdisk (for GPT and Syslinux)
- openssl/gpg (for encryption)
- Full system or partial backup
- Restore or transfer to the same or different disk/partition layout.
- Restore or transfer to an external device such as usb flash drive, sd card etc.
- Restore a BIOS-based system to UEFI and vice versa.
- Prepare a system in a virtual machine (such as virtualbox), back it up and restore it in a normal machine.
With this mode you can make a tar backup archive of your system. You can define:
- Archive filename: A desired name for the backup archive. Default is
Backup-$(hostname)-$(date +%Y%m%d-%H%M%S)
. - Destination directory: Set where you want to save the backup archive. Default is
/
. - Home directory: You have three options: fully include it, keep only it's hidden files and folders (which are necessary to login and keep basic settings) or completely exclude it (in case it's located in separate partition and you want to use that in restore mode).
- Compression: You can choose between gzip, bzip2, xz and none (for no compression). Gzip should be fine.
- Encryption method and passphrase: Select encryption method (openssl or gpg) and enter a passphrase if you want to encrypt the archive.
- Archiver options: You can pass your own extra options in the archiver. See
tar --help
for more info.
The script can read input from /etc/backup.conf. Alternative path can be specified: star.sh /path/backup.conf -i 0
or star-gui.sh /path/backup.conf
.
See the provided sample or use -g, --generate
to generate a configuration file.
When the process completes, you may want to check backup.log file in the same directory with the backup archive.
Restore mode uses the above created archive to extract it in desired partition(s). Transfer mode transfers your system in desired partition(s) using rsync. Then, in both cases, the script generates the target system's fstab, rebuilds initramfs for every available kernel, generates locales and finally installs and configures the selected bootloader.
Boot from a livecd - preferably one of the target (backed up) distro - or another existing system, prepare your target partition(s) and start the script. You can define:
- Target partitions: You must specify a target root partition. Optionally you can choose any other partition for your /home, /boot, swap or custom mount points (/var /opt etc.) and in case of UEFI a target ESP partition and it's mount point (/boot/efi or /boot).
- Mount options: You can specify alternative comma-seperated mount options for the target root partition. Defaults are
defaults,noatime
. - Btrfs subvolumes: If the target root filesystem is Btrfs, you can create subvolumes. Set the root subvolume name and also you can specify other subvolumes. Just enter the paths (/home /var /usr etc.) seperated by space. Recommended root subvolume name is
__active
. - Bootloader: In BIOS systems you can choose Grub (version 2) or Syslinux and the target device. If you select a raid array as bootloader device, the script will install the bootloader in all devices that the array contains. In case of UEFI you can choose Grub, EFISTUB/efibootmgr or Systemd/bootctl. Also you can define additional kernel options.
- Modes: In Restore mode you have to specify the backup archive (local path or remote url). If the archive is encrypted you must specify the passphrase. In Transfer mode you can choose if you want to transfer your entire /home directory, only it's hidden files and folders (which are necessary to login and keep basic settings) or exclude it.
- Tar/Rsync options: You may want to specify any additional options. See
tar --help
orrsync --help
for more info.
When the process completes check /tmp/restore.log.
See star.sh --help
for all available options.
-
In case of Gentoo initramfs is optional. You can use
-D, --use-genkernel
in Restore/Transfer mode to enable initramfs building via genkernel. -
In the target system, the script saves configuration files before generate/modify them with -old suffix.
-
In case of UEFI, you must boot in UEFI enviroment to restore a system. The script will check if /sys/firmware/efi exists and act accordingly. You must create an EFI System Partition.
-
Some tested Restore/Transfer scenarios are included in the table below.
Tested scenarios
TARGET PARTITION | MOUNTPOINT | BOOTLOADER | SYSTEM | NOTES |
---|---|---|---|---|
/dev/sdX1 | / | Grub Syslinux |
BIOS MBR | |
/dev/sdX2 /dev/sdX1 /dev/sdX3 /dev/sdX4 |
/ /boot /home /var |
Grub Syslinux |
BIOS MBR | |
/dev/md0 | / | Grub Syslinux |
BIOS MBR | level=1 metadata=1.0 |
/dev/md1 /dev/md0* |
/ /boot |
Syslinux | BIOS GPT | level=1 metadata=1.0* |
/dev/sdX2 /dev/sdX1 |
/ /boot |
Grub Syslinux |
BIOS MBR | btrfs Root Subvolume: __active Other Subvolumes: /home /usr /var /opt |
/dev/mapper/A-B /dev/sdX1* /dev/sdX3 |
/ /boot |
Grub Syslinux |
BIOS GPT | lvm Grub needs BIOS Boot Partition* |
/dev/mapper/A-B /dev/sdX1 /dev/mapper/A-C /dev/mapper/A-D /dev/mapper/X |
/ /boot /home swap |
Grub Syslinux |
BIOS MBR | lvm on luks |
/dev/mapper/A-B /dev/md1 /dev/md0* |
/ /boot |
Syslinux | BIOS GPT | lvm on mdadm level=1 metadata=1.0* |
/dev/mapper/A-B /dev/mapper/X /dev/md1 /dev/md0* |
/ /boot |
Syslinux | BIOS GPT | lvm on luks on mdadm level=1 metadata=1.0* |
/dev/mapper/X /dev/sdX1 |
/ /boot |
Grub Syslinux |
BIOS MBR | luks |
/dev/mapper/X /dev/A/B /dev/sdX1 |
/ /boot |
Grub Syslinux |
BIOS MBR | luks on lvm |
/dev/mapper/X /dev/md1 /dev/md0* |
/ /boot |
Syslinux | BIOS GPT | luks on mdadm level=1 metadata=1.0* |
/dev/mapper/X /dev/mapper/A-B /dev/md1 /dev/md0* |
/ /boot |
Syslinux | BIOS GPT | luks on lvm on mdadm level=1 metadata=1.0* |
/dev/sdX2 /dev/sdX1* |
/ /boot/efi |
Grub EFISTUB/efibootmgr Systemd/bootctl |
UEFI GPT | ESP* efibootmgr 0.12 efivar 0.21 systemd >= 222 |
/dev/sdX2 /dev/sdX1* |
/ /boot |
Grub EFISTUB/efibootmgr Systemd/bootctl |
UEFI GPT | ESP* efibootmgr 0.12 efivar 0.21 systemd >= 222 |
/dev/mapper/X /dev/sdX2 /dev/sdX1* |
/ /boot /boot/efi |
Grub EFISTUB/efibootmgr Systemd/bootctl |
UEFI GPT | luks ESP* efibootmgr 0.12 efivar 0.21 systemd >= 222 |
Backup Mode:
- Destination: /home/john/
- Compression: gzip
- Additional options: --exclude=/home/john/.cache/* --warning=none
star.sh -i 0 -d /home/john/ -c gzip -u "--exclude=/home/john/.cache/* --warning=none"
- Destination: /home/john/
- Compression: xz
- Exclude /home directory
star.sh -i 0 -d /home/john/ -c xz -H 2
- Destination: /home/john/
- Compression: bzip2
- Keep only /home's hidden files and folders
- Encryption
star.sh -i 0 -d /home/john/ -c bzip2 -E openssl -P 1234 -H 1
Restore Mode:
- root: /dev/sdb1
- grub
- local archive
star.sh -i 1 -r /dev/sdb1 -G /dev/sdb -f /home/john/backup.tar.gz
- root: /dev/sdb1, /home: /dev/sdb2, swap: /dev/sdb3
- syslinux
- remote archive on ftp server
star.sh -i 1 -r /dev/sdb1 -h /dev/sdb2 -s /dev/sdb3 -S /dev/sdb -f ftp://server/backup.tar.xz
- root: /dev/md1, /boot: /dev/md0
- local archive
- syslinux
star.sh -i 1 -r /dev/md1 -b /dev/md0 -f /home/john/backup.tar.gz -S /dev/md0
- root: /dev/sdb1
- syslinux
- remote file in protected http server
star.sh -i 1 -r /dev/sdb1 -S /dev/sdb -f http://server/backup.tar.gz -y username -p password
- root: /dev/sda2, esp: /dev/sda1
- local archive
- grub
star.sh -i 1 -r /dev/sda2 -e /dev/sda1 -l /boot/efi -G auto -f /home/john/backup.tar.gz
Transfer Mode:
- root: /dev/sda1 (ssd)
- syslinux
- kernel options: nomodeset
star.sh -i 2 -r /dev/sda1 -m discard,errors=remount-ro -S /dev/sda -k nomodeset
- root: /dev/mapper/debian-root, /boot: /dev/sdb1
- grub
star.sh -i 2 -r /dev/mapper/debian-root -b /dev/sdb1 -G /dev/sdb
- root: /dev/sda2 (btrfs with compression), /boot: /dev/sda1
- root subvolume: __active
- /var, /usr and /home subvolumes
- syslinux
star.sh -i 2 -r /dev/sda2 -m compress=lzo -b /dev/sda1 -S /dev/sda -R __active -B "/var /usr /home"
- root: /dev/sdb2, /boot: /dev/sdb1, /var: /dev/sdb4, /usr: /dev/sdb3
- transfer /home's hidden files and folders only
- grub
star.sh -i 2 -r /dev/sdb2 -b /dev/sdb1 -t "/var=/dev/sdb4 /usr=/dev/sdb3" -G /dev/sdb -H 1