system-tar-and-restore

授权协议 Readme
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 汲睿
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

System Tar & Restore

Backup

ABOUT

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

Stable Releases

DISTRIBUTION PACKAGES

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

REQUIREMENTS

  • 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)

THINGS YOU CAN DO

  • 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.

BACKUP MODE

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/TRANSFER MODE

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 or rsync --help for more info.

When the process completes check /tmp/restore.log.

See star.sh --help for all available options.

NOTES

  • 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

EXAMPLES USING ARGUMENTS

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

  • 最近要做linux系统的快速克隆与虚拟服务器部署,翻了很多论坛的教程,均卡在了最后一步恢复系统引导上,最后将几篇帖子里提到的内容串到一起捋了一遍才找到具体的实现方法 前提条件 恢复的目标服务器需先安装系统(与备份的系统一致,下方示例为centos) 恢复的目标服务器可用空间要大于所备份的系统(建议恢复的系统磁盘空间>=备份的系统磁盘空间) 恢复的目标服务器可以远程连接(可为跳板机+ssh) 操作步

  • 查看帮助信息 # tar --help Usage: tar [OPTION...] [FILE]... GNU 'tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive. Examples: tar -cf arc

  • 本文参考资料来源: http://man.linuxde.net/tar 一般使用gzip进行解压缩即用 tar -zcv -f 指定压缩包的名称.tar.gz  要被压缩的文件或文件夹 将当前目录下的ip.txt文件和ipuser.sh文件压缩打包放到/home目录下,压缩包为backup.tar.gz tar -zcvf /home/backup.tar.gz ip.txt ipuser.sh

  • tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 下面的参数-f是必须的

  • Usage: tar [OPTION...] [FILE]... GNU `tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive. Examples:   tar -cf archive.tar foo bar  # C

  • 说明:将一个工控机ubuntu16.04系统备分到其他工控机后者电脑上。只要新电脑硬盘容量大于备份文件即可,一般都会满足。 制作ubuntu16.04启动U盘 U盘启动,启动原工控机进入BIOS,U盘启动系统,进入Try ubuntu。 挂载原工控机硬盘,并打包原系统文件(linux系统全都是文件形式) (1) $sudo fdisk -l 命令查看磁盘符号,一般较大容量的硬盘为系统盘(单个硬盘工

  • tar === 将许多文件一起保存至一个单独的磁带或磁盘归档,并能从归档中单独还原所需文件。 ## 补充说明 **tar命令** 可以为linux的文件和目录创建档案。利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,

  • 一、zip 压缩格式 命令格式: [user@localhost ~]$ zip [选项] 压缩包名 源文件或源目录 1.1 压缩常用命令 1. 压缩文件: [user@localhost ~]$ zip file.zip file1.txt # 压缩当前目录下的file1.txt文件 [user@localhost ~]$ zip file.zip file1.txt f

  • 说明: KingbaseES V8R6版本中自带数据库备份导出sys_dump,和备份恢复sys_restore工具。 sys_dump:把KingbaseES数据库抽取为一个脚本文件或其他归档文件。数据库正在被并发使用,它也能创建一致的备份。但在日常使用中,建议在业务工作停止时做数据导出工作(不需要关闭数据库),以免对业务性能产生影响。 sys_restore:从一个由sys_dump创建的归档

  • Linux命令之tar详解 tar是Linux的内置命令,所以这个工具在安装完linux系统就有了。他是用来管理压缩包,可以 生成压缩包 解开压缩包 查看压缩包的内容 下面就解释用tar来完成这3个功能,并且给出例子 tar命令的选项有: -A, –catenate, –concatenate append tar files to an archive -c, –create create a

  • 1 tar 1.2 tar介绍 tar命令是linux系统中对文件和目录解压缩命令。tar命令可以用于对后缀名为.tar,tar.gz等常用文件。 1.3 tar参数 系统中通过tar --help查看: Main operation mode: -A, --catenate, --concatenate append tar files to an archive -c, --create cr

  • 首先安装基础依赖组建,注:这些依赖组建也是LINUX+PHP+MYSQL+APACHE+NGINX+MEMCACHED时必要的系统组件  LANG=C  yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel

  • 00. 目录 01. 命令概述 tar命令:用来压缩和解压文件。tar本身不具有压缩功能。他是调用压缩功能实现的 tar命令可以为linux的文件和目录创建档案。利用tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于

  • tar 相关命令: unzip, bzip2, gunzip, tar, rar, gzip  tar 命令:用来压缩和解压文件。tar本身不具有压缩功能。他是调用压缩功能实现的    主操作模式:  -A, --catenate, --concatenate   追加 tar 文件至归档  -c, --create               创建一个新归档  -d, --diff, --co

 相关资料
  • 1. Flash Partition and File System Management Kamino18 use MTD(Memory Technology Device)to control NOR FLASH and NAND FLASH. MTD layer isolate file system with FLASH driver.

  • tar

    在 Linux 系统上,打包与解压可以使用 tar。 选项 tar 有很多选项,记住它们不容易,先只需要记住常用的操作需要的选项。 c(create) 创建 z(gzip)一种压缩格式 f(file) 表示文件 x(extract) 表示解压 打包 需要 create file 这两个选项,打包生成的文件一般用 .tar 后缀。 tar --create --file 生成的打包文件.tar 要打

  • tar

    import "archive/tar" tar包实现了tar格式压缩文件的存取。本包目标是覆盖大多数tar的变种,包括GNU和BSD生成的tar文件。 参见: http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5 http://www.gnu.org/software/tar/manual/html_node/Standard.html h

  • Star 是一个快速的、POSIX兼容的 tar 打包工具,可将多个文件保存到磁带或者是磁盘卷中,或者从卷中恢复出一个或多个文件。

  • 我有一个tar存档,其中包含一些其他tar存档。下面的示例完美地提取了primary.tar文件,但我在访问其中的其他.tar文件时遇到了问题。 这将返回以下内容: 所以我可以访问tar1.tar文件对象。但是,我无法弄清楚如何从tar1.tar中获取成员或内容。

  • 下表列出了各种系统调用及其说明。 类别 系统调用 描述 General 打开() 此系统调用将打开现有文件或创建并打开新文件。 General creat() 创建并打开一个新文件。 General 读() 将文件的内容读入所需的缓冲区。 General 写() 将缓冲区的内容写入文件。 General 关 () 关闭文件描述符。 General stat() 提供有关该文件的信息。 Pipes