- Relax-and-Recover – Backup and Recover a Linux System
- Relax-and-Recover Key Features:
- Step 1: Installing ReaR in Linux Bare Metal Server
- Step 2: Creating a Rescue System and a Full-System Backup
- Optional: Scheduling Rear Operations Using Cron
- Step 3: Performing a System Rescue/Restoration
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Relax-and-Recover
- Usage scenarios
- Recovery from USB
- Rescue system
- Storing on a central NFS server
- Backup integration
- Monitoring integration
- Relax-and-Recover
- Download Relax-and-Recover
- Stable releases
- Master branch snapshot
- Distribution packages
- Fedora
- openSUSE
- RHEL, CentOS, Scientific Linux, Oracle Linux
- OpenSUSE Build Service packages
- Official stable releases
- Snapshot releases from Git
- Future releases
- Резервное копирование с помощью Bareos и Relax-and-Recover
- Настройка сервера Bareos
- Настройка клиента Bareos.
- Запуск бэкапа/восстановления
- Установка и настройка Relax-and-Recover
Relax-and-Recover – Backup and Recover a Linux System
Relax-and-Recover (ReaR in short) is a simple yet powerful, easy-to-setup, full-featured and leading open-source bare metal disaster recovery and system migration solution, written in Bash. It is a modular and configurable framework with numerous ready-to-use workflows for common situations.
ReaR creates a bootable rescue system and/or system backup in various formats. You can boot your bare metal server using the rescue system image and initiate a system restore from the backup. It can restore to different hardware where necessary, hence it can also be employed as a system migration tool.
Relax-and-Recover Key Features:
- It has a modular design written in Bash and can be extended using custom functionality.
- Supports various boot media including ISO, PXE, OBDR tape, USB or eSATA storage.
- Supports a variety of network protocols including FTP, SFTP, HTTP, NFS, and CIFS for storage and backup.
- Supports disk layout implementation such as LVM, DRBD, iSCSI, HWRAID (HP SmartArray), SWRAID, multipathing, and LUKS (encrypted partitions and filesystems).
- Supports both third-party and internal backup tools including IBM TSM, HP DataProtector, Symantec NetBackup, Bacula; tar and rsync.
- Supports booting via PXE, DVD/CD, bootable tape or virtual provisioning.
- Supports a simulation model that shows what scripts are run without executing them.
- Supports consistent logging and advanced debugging options for troubleshooting purposes.
- It can be integrated with monitoring tools such as Nagios and Opsview.
- It can also be integrated with job schedulers such as cron.
- It also supports various virtualization technologies supported (KVM, Xen, VMware).
In this article, you will learn how to install and configure ReaR to create a rescue system and/or system backup using a USB stick and rescue or restore a bare-metal Linux system after a disaster.
Step 1: Installing ReaR in Linux Bare Metal Server
1. To install the rear package on Debian and Ubuntu Linux distributions, use the following command.
On RHEL and CentOS, you need to enable the EPEL 8 repository, then install the rear package as shown.
2. Once the installation is complete, rear’s main configuration directory is /etc/rear/ and the key configuration files are:
- /etc/rear/local.conf – used to set system-specific configuration; it’s intended for manual configuration.
- /etc/rear/site.conf– used to set site-specific configuration, should be created by the user.
- /usr/share/rear/conf/default.conf – contains possible/default configuration values.
- /var/log/rear/ – this directory stores the log files.
3. First, prepare the rescue media, a USB stick in this case by formatting using the rear command-line utility as follows. Once the formatting is complete, the media will be labeled as REAR-000.
Prepare Rescue Media
4. To configure the output format, use the OUTPUT and OUTPUT_URL variables, enter it in the /etc/rear/local.conf configuration file.
4. Also, ReaR comes with a built-in backup method (called NETFS) which allows you to create both a rescue system and a full-system backup. It creates a simple backup as a tar archive by default.
To enable a full-system backup, add the BACKUP=NETFS and BACKUP_URL variables in the /etc/rear/local.conf configuration file. To create a bootable USB device, combine OUTPUT=USB and BACKUP_URL=”usb:///dev/disk/by-label/REAR-000” as shown.
5. After configuring the rear, run the following command to print out its current configuration for BACKUP and OUTPUT methods and some system information.
Rear Backup Configuration Settings
Step 2: Creating a Rescue System and a Full-System Backup
6. If all the settings are fine, you can create a rescue system using the mkrecue command as follows, where the -v option enables verbose mode.
Make Rescue System
Note: If you encounter the following error after running a rescue or backup operation, as shown in this screenshot.
USB Stick Format Error
Format the USB stick using this command and redo the operation.
Format USB
7. To create a rescue system and backup the system as well, use the mkbackup command as shown.
8. To create a full-system backup only, use the mkbackuponly command as follows.
Optional: Scheduling Rear Operations Using Cron
8. You can schedule ReaR to regularly create a rescue system using the cron job scheduler by adding the appropriate entry in the /etc/crontab file.
The following configurations will create a rescue system or take a full-system backup every midnight. Ensure that your USB stick is attached to it.
Step 3: Performing a System Rescue/Restoration
9. To restore/recover your system after a disaster, connect the bootable USB stick to your bare metal system and boot from it. In the console interface, select option one (Recover hostname) and click Enter.
ReaR Main Boot Menu
10. Next, the ReaR rescue system will be configured, you may be prompted to provide replacements for the original network interfaces as shown in the screenshot. Once you are done, click Enter.
Select Network Interface
11. Then login as root (just type username root and click Enter) to run the actual recovery.
Run System Recovery
11. Next, run the following command to launch the recovery process. The rescue system will compare the disks, examine their configurations and prompt you to choose disk layout configuration. Press Enter to proceed with auto disk configuration.
Then it will start the system layout restoration, once the disk layout is created, it will restore the backup as shown in the following screenshot.
ReaR Recover Method
12. When the backup restoration is complete, the rescue system will run mkinitrd to create initial ramdisk images for preloading modules, then install the boot loader and exits. One the system recovery is done, the restored system will be mounted under /mnt/local/ , move into this directory to examine it.
Finally, reboot the system:
Explore Restored System
13. After a reboot, the SELinux will try to relabel files and file systems on the recovered system based on /mnt/local/.autorelabel file, as shown in the following screenshot.
Relabeling File System
For more usage options, read the ReaR manual page.
The ReaR is the leading, easy-to-use (setup-and-forget) and open source bare metal disaster recovery and system migration framework. In this article, we explained how to use ReaR to create a Linux bare metal rescue system and backup and how to restore a system after a disaster. Use the comment form below share your thoughts with us.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Relax-and-Recover
Usage scenarios
Recovery from USB
Prepare your rescue media using
It will be labeled REAR-000. The /etc/rear/local.conf can be as simple as:
Run rear -v mkbackup to create the rescue media including the archive of the Operating System.
Rescue system
Relax-and-Recover will not automatically add itself to the Grub bootloader. It copies itself to your /boot folder.
To enable this, add
to your local configuration.
The entry in the bootloader is password protected. The default password is REAR. Change it in your own local.conf
Storing on a central NFS server
The most straightforward way to store your DR images is using a central NFS server. The configuration below will store both a backup and the rescue CD in a directory on the share.
Backup integration
Relax-and-Recover integrates with various backup solutions. Your backup software takes care of backing up all system files, Relax-and-Recover recreates the filesystems and starts the file restore.
Currently Bacula, Bareos, SEP Sesam, HP DataProtector, CommVault Galaxy, Symantec NetBackup, EMC NetWorker (Legato), FDR/Upstream, and IBM Tivoli Storage Manager are supported.
The following /etc/rear/local.conf uses a USB stick for the rescue system and Bacula for backups. Multiple systems can use the USB stick since the size of the rescue system is probably less than 40M. It relies on your Bacula infrastructure to restore all files.
Monitoring integration
Relax-and-Recover integrates with your monitoring. The rear checklayout command will tell you if the most recent rescue environment deviates from your storage configuration (e.g. LVM changes, filesystem resized, …)
In good Unix tradition rear checklayout returns 0 if your system is in sync with your rescue image. A return code of 1 should lead to a red light in your monitoring screen because a new rescue image is needed. Create a rescue image and the next time rear checklayout runs, it will return 0 again, and your monitoring will switch to green.
You can also automate the creation of rescue images by adding a cron job for /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue . And make sure the OUTPUT_URL points to a central location for storing your rescue images. By default, a rear installation via a package manager will automatically install a cron entry — see:
Furthermore, rear will write an exit code to the /var/log/messages file which you could use to search via an integrated monitoring system (search for the rear keyword).
Источник
Relax-and-Recover
Download Relax-and-Recover
The project announces new releases on the low-traffic rear-announce mailinglist.
Stable releases
The various stable releases are available as tar.gz files from the Sourceforge Downloads page.
Master branch snapshot
The latest development snapshot is available through the Github Download ZIP button.
All stable releases are available via the Github ReaR releases page.
Or you can get a private source copy through:
Distribution packages
Various distributions ship Relax-and-Recover as part of their distribution, albeit not always the latest stable release. Here is an overview:
Fedora
openSUSE
RHEL, CentOS, Scientific Linux, Oracle Linux
ReaR is not part anymore of EPEL as it is now part of the distribution repositories.
OpenSUSE Build Service packages
If you are looking for newer stable release or snapshot release, take a look at our automated builds from the OpenSUSE Build Service:
Official stable releases
Since rear release 1.17.2 you will find the stable packages under the architecture directory, e.g. i586 or x86_64 instead of noarch. Previous release are still kept under the noarch sub-directory.
Snapshot releases from Git
- CentOS: 6.0, 7.08.0
- Debian: 7.0, 8.0, 9.010.0
- Fedora: 32, 33, Rawhide
- openSUSE: 13.1, 13.2, Factory, Factory_PowerPC, Tumbleweed, Leap_42.2, Leap_42.3, Leap_15.0, Leap_15.1, Leap_15.2, Leap_15.3
- RHEL: 5, 6, 7
- ScientificLinux: 6, 7
- SLES: 10, 11, 11_SP1, 11_SP2, 11_SP3, 11_SP4, 12, 12_SP1, 12_SP2, 12_SP3, 12_SP4, 12_SP5, 15, 15_SP1, 15_SP2, 15_SP3
- Ubuntu: 12.04, 14.04, 16.04, 16.10, 17.04, 17.10, 18.04, 18.10, 19.04, 19.10, 20.04, 20.10
Future releases
Future releases are planned and communicated through Github milestones
Источник
Резервное копирование с помощью Bareos и Relax-and-Recover
Bareos (Backup Archiving Recovery Open Sourced) является централизованной, клиент-серверной и кроссплатформерной системой для резервного копирования, архивирования и восстановления данных.
Является форком Bacula и активно развивается. Имеет клиенты под Linux и Windows. Полный список поддерживаемых фич на Github.
Принципы работы и конфигурация полностью совпадают с Bacula, поэтому подробно останавливаться на описании всех параметров не буду. Статьи о Bacula есть на Хабре («Пошаговая модификация предустановленной настройки Bacula», «Bacula: для тех кому надо по-быстрому и в картинках», «Настройка и понимание Bacula», «Централизованное резервное копирование данных Windows и *nix серверов средствами Bacula»).
Хосты:
testbackup-bareos – сервер Bareos, на котором работают bconsole, bareos-director, file daemon, storage daemon. IP адрес – 10.11.0.150
testbackup-client-03 – клиент, который мы бэкапим. ОС Роса Кобальт 1.0. На нём работает file-daemon. IP адрес – 10.11.0.153
Настройка сервера Bareos
Я выбрал Bareos 15.Х, так как здесь улучшена работа с сокетами. Но данная инструкция также подойдёт и для ветки 14.X.
Устанавливаем Bareos из репозитория и настраиваем PostgreSQL:
Конфигурация клиента находится в каталоге /etc/bareos/bareos-dir.d:
Здесь создано 4 задания – 2 Job для бэкапа/восстановления всей системы (/ и /boot) и 2 Job для бэкапа/восстановления БД MySQL Zabbix с использованием пайпа (bpipe). В нашем примере бэкап БД делается лишь для демонстрации работы bpipe. Дамп базы не сохраняется локально у клиента, он сразу передаётся по сети.
plugin – имя плагина без приставки -fd.so;
filepath – псевдопуть в Volume к файлу бэкапа. Этот путь и имя файла необходимы только для логического представления в дереве каталога при восстановлении;
readprogram – программа, stdout которой считывает bpipe и передаёт на сервер;
writeprogram – программа, в stdin которой bpipe передаёт данные с сервера.
Конфигурация Director в каталоге /etc/bareos:
Конфигурация Storage Daemon в каталоге /etc/bareos:
Если имя клиента не резолвится, то прописываем в /etc/hosts:
echo «10.11.0.153 testbackup-client-03» >> /etc/hosts
Запускаем Director, File Daemon и Storage:
На этом настройка сервера Bareos закончена. Переходим к настройке клиента testbackup-client-03.
Настройка клиента Bareos.
Устанавливаем репозиторий bareos и ставим File Daemon:
Конфигурация File Daemon в каталоге /etc/bareos:
На этом настройка клиента закончена.
Запуск бэкапа/восстановления
Идём на сервер testbackup-bareos и запускаем бэкап базы данных MySQL и полный бэкап:
Для восстановления базы данных нужно запустить соответствующую задачу:
И следовать по предлагаемым пунктам.
Или, если мы знаем JobId (например, 158), то сразу запустить:
Установка и настройка Relax-and-Recover
REAR (Relax-and-Recover) это решение Linux BMDR (Bare Metal Disaster Recovery), восстановление системы на чистое железо.
Основные фичи:
- Восстановление на чистое железо: physical-to-virtual (P2V), virtual-to-physical (V2P), physical-to-physical (P2P) and virtual-to-virtual (V2V), системы виртуализации KVM, Xen, VMware
- Типы загрузочных устройств: ISO, USB, eSATA, OBDR/bootable tape, PXE
- Протоколы для передачи данных: HTTP, HTTPS, FTP, SFTP, NFS, CIFS (SMB)
- Виды разбивки диска: HWRAID (HP SmartArray), SWRAID, LVM, multipathing, DRBD, iSCSI, LUKS (encrypted partitions and filesystems)
- Бэкэнды: CommVault Galaxy, EMC NetWorker (Legato), HP DataProtector, IBM Tivoli Storage Manager (TSM), SEP Sesam, Symantec NetBackup, Bacula, Bareos, duplicity / duply
Остальные фичи есть на сайте.
В нашем примере рассмотрим создание загрузочного образа ISO и полное восстановление системы клиента testbackup-client-03, используя в качестве бэкэнда Bareos.
Загрузочный ISO-образ создаётся на клиенте и передаётся по NFS на сервер (в нашем случае на сервер Bareos) в папку nfs://10.11.0.150/backup
Для этого предварительно необходимо на сервере настроить доступ по NFS.
После переходим к настройке клиента testbackup-client-03:
Для нашего дистрибутива РОСА Кобальт подключаем репозиторий EPEL:
Закомментируем mirrorlist и раскомментируем baseurl в /etc/yum.repos.d/epel.repo:
И импортируем GPG-ключ:
Устанавливаем REAR и необходимые компоненты:
В файлы ip_addresses и route добавляем информацию о ip, интерфейсе и дефолтном шлюзе:
Во избежание проблем с определением имён Job, Client рекомендую, чтобы имя File Daemon клиента точно соответствовало его hostname. Т.е. если hostname сервера testbackup-client-03, то в bareos-fd.conf в секции FileDaemon должно быть написано:
Name = testbackup-client-03-fd
Настраиваем local.conf из шаблона:
Не публикую полную конфигурацию local.conf т.к. я изменил лишь следующие параметры в сравнении с default.conf:
Так как я использую дистрибутив РОСА Кобальт (rhel-based версии 6.6) и поэтому я установил OS_VENDOR и OS_VERSION как для CentOS 6.6.
Для наглядности я использую свой шаблон имён для Job, File Set, Client, поэтому необходимо отредактировать скрипт восстановления REAR, иначе скрипт не найдёт все необходимые данные.
И там же (перед ней, например) задаём новую переменную:
Делаем загрузочный ISO:
Для информации: полученный размер ISO составляет порядка 30-40 МБ.
Для восстановления загружаемся с данного образа и выбираем Recover testbackup-client-03.
Запускаем процесс восстановления:
По окончании процесса восстановления проверяем нашу систему, которая примонтирована в /mnt/local.
Убеждаемся, что всё на месте и перезагружаемся:
Система полностью восстановлена.
Прежде чем использовать загрузочный образ для какой-либо ОС, я рекомендую его предварительно протестировать.
Источник