LINUX系统备份工具 REAR
HTTP://RELAX-AND-RECOVER.ORG/DOWNLOAD/
HTTPS://ACCESS.REDHAT.COM/DOCUMENTATION/EN-US/RED_HAT_ENTERPRISE_LINUX/7/HTML/SYSTEM_ADMINISTRATORS_GUIDE/CH-RELAX-AND-RECOVER_REAR

CHAPTER 28. RELAX-AND-RECOVER (REAR)

When a software or hardware failure breaks the system, the system administrator faces three tasks to restore it to the fully functioning state on a new hardware environment:
  1. booting a rescue system on the new hardware
  2. replicating the original storage layout
  3. restoring user and system files
Most backup software solves only the third problem. To solve the first and second problems, use Relax-and-Recover (ReaR), a disaster recovery and system migration utility.
Backup software creates backups. ReaR complements backup software by creating a rescue system. Booting the rescue system on a new hardware allows you to issue the rear recovercommand, which starts the recovery process. During this process, ReaR replicates the partition layout and filesystems, prompts for restoring user and system files from the backup created by backup software, and finally installs the boot loader. By default, the rescue system created by ReaR only restores the storage layout and the boot loader, but not the actual user and system files.
This chapter describes how to use ReaR.

28.1. Basic ReaR Usage

28.1.1. Installing ReaR

=============centos6.9=====================
mtools-4.0.12-1.el6.x86_64.rpm#syslinux依赖包
parted-2.1-29.el6.x86_64.rpm#rear依赖包
dosfstools-3.0.9-4.el6.x86_64.rpm#rear依赖包
genisoimage-1.1.9-12.el6.x86_64.rpm#生成iso工具
rear-2.00-1.fc25.x86_64.rpm#系统备份工具
syslinux-4.02-8.el6.x86_64.rpm#启动引导工具

=========================================
Install the rear package and its dependencies by running the following command as root:

~]# yum install rear genisoimage syslinux

28.1.2. Configuring ReaR

ReaR is configured in the /etc/rear/local.conf file. Specify the rescue system configuration by adding these lines:
OUTPUT=output format
OUTPUT_URL=output location
Substitute output format with rescue system format, for example, ISO for an ISO disk image or USB for a bootable USB.
Substitute output location with where it will be put, for example,file:///mnt/rescue_system/ for a local filesystem directory orsftp://backup:password@192.168.0.0/ for an SFTP directory.

Example 28.1. Configuring Rescue System Format and Location

To configure ReaR to output the rescue system as an ISO image into the/mnt/rescue_system/ directory, add these lines to the /etc/rear/local.conf file:
OUTPUT=ISO
OUTPUT_URL=file:///mnt/rescue_system/

See section "Rescue Image Configuration" of the rear(8) man page for a list of all options.

ISO-specific Configuration

Using the configuration in Example 28.1, “Configuring Rescue System Format and Location”results into two equivalent output files in two locations:
  • /var/lib/rear/output/ - rear's default output location
  • /mnt/rescue_system/HOSTNAME/rear-localhost.iso - output location specified inOUTPUT_URL
However, usually you need only one ISO image. To make ReaR create an ISO image only in the directory specified by a user, add these lines to /etc/rear/local.conf:
OUTPUT=ISO
BACKUP=NETFS
OUTPUT_URL=null
BACKUP_URL="iso:///backup"
ISO_DIR="output location"
Substitute output location with the desired location for the output.

28.1.3. Creating a Rescue System

The following example shows how to create a rescue system with verbose output:
~]# rear -v mkrescue
Relax-and-Recover 1.17.2 / Git
Using log file: /var/log/rear/rear-rhel7.log
mkdir: created directory '/var/lib/rear/output'
Creating disk layout
Creating root filesystem layout
TIP: To login as root via ssh you need to set up /root/.ssh/authorized_keys or SSH_ROOT_PASSWORD in your configuration file
Copying files and directories
Copying binaries and libraries
Copying kernel modules
Creating initramfs
Making ISO image
Wrote ISO image: /var/lib/rear/output/rear-rhel7.iso (124M)
Copying resulting files to file location
With the configuration from Example 28.1, “Configuring Rescue System Format and Location”, ReaR prints the above output. The last two lines confirm that the rescue system has been successfully created and copied to the configured backup location/mnt/rescue_system/. Because the system's host name is rhel7, the backup location now contains directory rhel7/ with the rescue system and auxiliary files:
~]# ls -lh /mnt/rescue_system/rhel7/
total 124M
-rw-------. 1 root root  202 Jun 10 15:27 README
-rw-------. 1 root root 166K Jun 10 15:27 rear.log
-rw-------. 1 root root 124M Jun 10 15:27 rear-rhel7.iso
-rw-------. 1 root root  274 Jun 10 15:27 VERSION
Transfer the rescue system to an external medium to not lose it in case of a disaster.

28.1.4. Scheduling ReaR

To schedule ReaR to regularly create a rescue system using the cron job scheduler, add the following line to the /etc/crontab file:
minute hour day_of_month month day_of_week root /usr/sbin/rear mkrescue
Substitute the above command with the cron time specification (described in detail inSection 22.1.2, “Scheduling a Cron Job”).

Example 28.2. Scheduling ReaR

To make ReaR create a rescue system at 22:00 every weekday, add this line to the/etc/crontab file:
0 22 * * 1-5 root /usr/sbin/rear mkrescue

28.1.5. Performing a System Rescue

To perform a restore or migration:
  1. Boot the rescue system on the new hardware. For example, burn the ISO image to a DVD and boot from the DVD.
  2. In the console interface, select the "Recover" option:

    Figure 28.1. Rescue system: menu

  3. You are taken to the prompt:
    1. Figure 28.2. Rescue system: prompt

      Warning

      Once you have started recovery in the next step, it probably cannot be undone and you may lose anything stored on the physical disks of the system.

    2. Run the rear recover command to perform the restore or migration. The rescue system then recreates the partition layout and filesystems:

      Figure 28.3. Rescue system: running "rear recover"

    3. Restore user and system files from the backup into the /mnt/local/ directory.

      Example 28.3. Restoring User and System Files

      In this example, the backup file is a tar archive created per instructions inSection 28.2.1.1, “Configuring the Internal Backup Method”. First, copy the archive from its storage, then unpack the files into /mnt/local/, then delete the archive:
      ~]# scp root@192.168.122.7:/srv/backup/rhel7/backup.tar.gz /mnt/local/
      ~]# tar xf /mnt/local/backup.tar.gz -C /mnt/local/
      ~]# rm -f /mnt/local/backup.tar.gz
      The new storage has to have enough space both for the archive and the extracted files.

    4. Verify that the files have been restored:
      ~]# ls /mnt/local/

      Figure 28.4. Rescue system: restoring user and system files from the backup

    5. Ensure that SELinux relabels the files on the next boot:
      ~]# touch /mnt/local/.autorelabel
      Otherwise you may be unable to log in the system, because the /etc/passwd file may have the incorrect SELinux context.
    6. Finish the recovery by entering exit. ReaR will then reinstall the boot loader. After that, reboot the system:

      Figure 28.5. Rescue system: finishing recovery

      Upon reboot, SELinux will relabel the whole filesystem. Then you will be able to log in to the recovered system.
====================================================================================================

Linux 系统全备份方法

====================================================================================================

28.2. INTEGRATING REAR WITH BACKUP SOFTWARE

The main purpose of ReaR is to produce a rescue system, but it can also be integrated with backup software. What integration means is different for the built-in, supported, and unsupported backup methods.

28.2.1. The Built-in Backup Method

ReaR ships with a built-in, or internal, backup method. This method is fully integrated with ReaR, which has these advantages:
  • a rescue system and a full-system backup can be created using a singlerear mkbackup command
  • the rescue system restores files from the backup automatically
As a result, ReaR can cover the whole process of creating both the rescue system and the full-system backup.

28.2.1.1. Configuring the Internal Backup Method

To make ReaR use its internal backup method, add these lines to/etc/rear/local.conf:
BACKUP=NETFS
BACKUP_URL=backup location
These lines configure ReaR to create an archive with a full-system backup using the tar command. Substitute backup location with one of the options from the "Backup Software Integration" section of the rear(8) man page. Make sure that the backup location has enough space.

Example 28.4. Adding tar Backups

To expand the example in Section 28.1, “Basic ReaR Usage”, configure ReaR to also output a tar full-system backup into the /srv/backup/ directory:
OUTPUT=ISO
OUTPUT_URL=file:///mnt/rescue_system/
BACKUP=NETFS
BACKUP_URL=file:///srv/backup/

The internal backup method allows further configuration.
  • To keep old backup archives when new ones are created, add this line:
    NETFS_KEEP_OLD_BACKUP_COPY=y
  • By default, ReaR creates a full backup on each run. To make the backups incremental, meaning that only the changed files are backed up on each run, add this line:
    BACKUP_TYPE=incremental
    This automatically sets NETFS_KEEP_OLD_BACKUP_COPY to y.
  • To ensure that a full backup is done regularly in addition to incremental backups, add this line:
    FULLBACKUPDAY="Day"
    Substitute "Day" with one of the "Mon", "Tue", "Wed", "Thu". "Fri", "Sat", "Sun".
  • ReaR can also include both the rescue system and the backup in the ISO image. To achieve this, set the BACKUP_URL directive toiso:///backup/:
    BACKUP_URL=iso:///backup/
    This is the simplest method of full-system backup, because the rescue system does not need the user to fetch the backup during recovery. However, it needs more storage. Also, single-ISO backups cannot be incremental.

    Example 28.5. Configuring Single-ISO Rescue System and Backups

    This configuration creates a rescue system and a backup file as a single ISO image and puts it into the /srv/backup/ directory:
    OUTPUT=ISO
    OUTPUT_URL=file:///srv/backup/
    BACKUP=NETFS
    BACKUP_URL=iso:///backup/

    Note

    The ISO image might be large in this scenario. Therefore, Red Hat recommends creating only one ISO image, not two. For details, see the section called “ISO-specific Configuration”.

  • To use rsync instead of tar, add this line:
    BACKUP_PROG=rsync
    Note that incremental backups are only supported when using tar.

28.2.1.2. Creating a Backup Using the Internal Backup Method

With BACKUP=NETFS set, ReaR can create either a rescue system, a backup file, or both.
  • To create a rescue system only, run:
    rear mkrescue
  • To create a backup only, run:
    rear mkbackuponly
  • To create a rescue system and a backup, run:
    rear mkbackup
Note that triggering backup with ReaR is only possible if using the NETFS method. ReaR cannot trigger other backup methods.

Note

When restoring, the rescue system created with theBACKUP=NETFS setting expects the backup to be present before executing rear recover. Hence, once the rescue system boots, copy the backup file into the directory specified inBACKUP_URL, unless using a single ISO image. Only then runrear recover.

To avoid recreating the rescue system unnecessarily, you can check whether storage layout has changed since the last rescue system was created using these commands:
~]# rear checklayout
~]# echo $?
Non-zero status indicates a change in disk layout. Non-zero status is also returned if ReaR configuration has changed.

Important

The rear checklayout command does not check whether a rescue system is currently present in the output location, and can return 0 even if it is not there. So it does not guarantee that a rescue system is available, only that the layout has not changed since the last rescue system has been created.

Example 28.6. Using rear checklayout

To create a rescue system, but only if the layout has changed, use this command:
~]# rear checklayout || rear mkrescue

28.2.2. Supported Backup Methods

In addition to the NETFS internal backup method, ReaR supports several external backup methods. This means that the rescue system restores files from the backup automatically, but the backup creation cannot be triggered using ReaR.
For a list and configuration options of the supported external backup methods, see the "Backup Software Integration" section of the rear(8) man page.

28.2.3. Unsupported Backup Methods

With unsupported backup methods, there are two options:
  1. The rescue system prompts the user to manually restore the files. This scenario is the one described in "Basic ReaR Usage", except for the backup file format, which may take a different form than a tar archive.
  2. ReaR executes the custom commands provided by the user. To configure this, set the BACKUP directive to EXTERNAL. Then specify the commands to be run during backing up and restoration using theEXTERNAL_BACKUP and EXTERNAL_RESTORE directives. Optionally, also specify the EXTERNAL_IGNORE_ERRORS and EXTERNAL_CHECK directives. See /usr/share/rear/conf/default.conf for an example configuration.

28.2.4. Creating Multiple Backups

With the version 2.00, ReaR supports creation of multiple backups. Backup methods that support this feature are:
  • BACKUP=NETFS (internal method)
  • BACKUP=BORG (external method)
You can specify individual backups with the -C option of the rearcommand. The argument is a basename of the additional backup configuration file in the /etc/rear/ directory. The method, destination, and the options for each specific backup are defined in the specific configuration file, not in the main configuration file.
To perform the basic recovery of the system:

Procedure 28.1. Basic recovery of the system

  1. Create the ReaR recovery system ISO image together with a backup of the files of the basic system:

      ~]# rear -C basic_system mkbackup

  2. Back the files up in the /home directories:

      ~]# rear -C home_backup mkbackuponly

Note that the specified configuration file should contain the directories needed for a basic recovery of the system, such as /boot/root, and/usr.

Procedure 28.2. Recovery of the system in the rear recovery shell

To recover the system in the rear recovery shell, use the following sequence of commands:
  1.   ~]# rear -C basic_system recover

  2.   ~]# rear -C home_backup restoreonly

Linux系统备份工具 REAR (RELAX-AND-RECOVER)相关推荐

  1. linux备份软件rear,linux系统 备份与还原

    linux 系统备份与还原 备份系统: 1. 成为 root 用户: su root 2. 进入根目录: cd / 3. 用tar命令打包压缩: tar cvpjf 压缩包名.tar.bz2 --ex ...

  2. linux硬盘对拷 再生龙,再生龙恢复linux系统备份教程

    教程1 再生龙备份恢复 说明:准备两个u盘,一个做再生龙的启动盘,一个做存储镜像文件的盘 1. 下载再生龙 2. 下载工具tuxboot制作u启 (1) https://sourceforge.net ...

  3. Linux备份检查工具,6种优化Linux系统备份的应用与技巧

    原标题:6种优化Linux系统备份的应用与技巧 当转为使用Linux时,你可能会注意到你所使用的版本会带有一个默认的备份工具.然而,可能该工具并没有被设置好去备份你系统中所有重要的部分.而且,使用该默 ...

  4. 利用系统工具进行服务器备份,服务器系统备份工具

    服务器系统备份工具 内容精选 换一换 GPU加速型p2(physical.p2.large规格)裸金属服务器创建成功后,需安装NVIDIA GPU驱动和CUDA工具包,从而实现计算加速功能.已绑定弹性 ...

  5. 服务器系统备份文档,服务器系统备份工具

    服务器系统备份工具 内容精选 换一换 建议不要在分析任务执行过程中卸载,否则可能出现异常.IDE插件只支持以Web模式卸载工具,不支持以CLI模式卸载工具.没有正在运行中的任务.配置参数后单击&quo ...

  6. 如何在linux系统中还原系统版本,系统还原也简单 常用Linux系统还原工具推荐

    据调查发现,一直以来,计算机用户都会被电脑死机.硬盘崩溃和内存芯片损耗过量等问题困扰,而最好的解决方式便是系统还原."系统还原"的目的是在不需要重新安装操作系统,也不会破坏数据文件 ...

  7. linux怎么用启动u盘恢复系统,一种U盘引导下的linux系统备份还原方法与流程

    本发明涉及的是一种U盘引导下的linux系统备份还原方法. 背景技术: 在现有技术中,公知的技术是数据信息时代数据迅速的增长趋势,需要对已有数据进行有效备份,以便故障发生后能快速有效的对系统进行恢复. ...

  8. 使用tar或dd等完成Linux系统备份恢复

    2019独角兽企业重金招聘Python工程师标准>>> 使用tar或dd等完成Linux系统备份恢复 本文提供一个简明常用的系统备份方法,使你可以迅速完成最常用最基本的备份工作. 需 ...

  9. Linux系统安全工具之:Sxid和Skey(转)

    Linux系统安全工具之:Sxid和Skey(转)[@more@]本文仅做参考 下面介绍一些可以用于 Linux 的安全工具,这些工具对于固化您的服务器将起到一定的作用,可以解决各方面的问题.我们的重 ...

  10. linux系统备份方案--ghost网络篇(转)

    linux系统备份方案--ghost网络篇(转)[@more@] 一.前言 一直以来,系统备份都是网络管理的必备环节.系统备份的方案有很多,各自有各自的优点和缺点,本文给大家提供一种新的选择.使用no ...

最新文章

  1. 比尔.盖茨11点忠告
  2. sys.argv[]学习
  3. python存储numpy数据为文件_numpy.savetxt是否将数组保存到文件中的特定位置?
  4. Oracle 10G DataGuard搭建
  5. PolarMask:单阶段实例分割框架,FCOS进阶!
  6. Django框架深入了解_05 (Django中的缓存、Django解决跨域流程(非简单请求,简单请求)、自动生成接口文档)(一)
  7. Java与.NET的WebServices相互调用
  8. 文本编辑器查看 cprintf颜色_airWriter for mac(文本编辑软件)
  9. oracle path函数,自定义类似 sys_connect_by_path 功能的函数
  10. jquery给title标签赋值
  11. java获取汉字的拼音首字母_java获取汉字的拼音首字母
  12. vector 简单使用
  13. 仿直播礼物涂鸦/屏幕礼物涂鸦动画
  14. Linux编程基础 5.2:消息队列
  15. 谷歌浏览器怎么长截图怎么截_Google浏览器如何截取网页长图 - 里维斯社
  16. 丢掉Axure,大厂PM最通用的原型设计工具
  17. 文献笔记:Plasmonic metagratings for simultaneous determination of Stokes parameters
  18. u盘坏了数据可以恢复吗?实用小方法
  19. 小程序 朋友圈,点赞 ,评论,发布动态,功能,上传图片 -----发布动态
  20. python 上传图片到七牛云上

热门文章

  1. 数据挖掘——无量纲化
  2. RPLIDAR思岚雷达学习记录--6--matlab处理雷达数据
  3. cesium--entity
  4. C#自学29—简体字繁体字转换
  5. 品牌制造商做电子商务的成本结构分析
  6. 周凯:如何利用数据挖掘让RTB广告效果倍增?
  7. win+L 锁屏快捷键 失效
  8. Altium Designer 18中的System–Design Insight
  9. iOS Swift之RxSwift初探
  10. Git汇总--版本库操作