IBM Support

UbuntuのSystem Backup(Relax and Recover)

Technical Blog Post


Abstract

UbuntuのSystem Backup(Relax and Recover)

Body

Deep Learning用途をはじめとしたUbuntuのご相談が増えています。

特に検証用途など頻繁に入れ替えをするような使い方で、「ベアメタルのUbuntuを簡単にバックアップしておく方法ない?」とご相談をいただきますのでOSSの「Relax and Recover」(REAR)を使用したシステムバックアップとリストアの方法をご紹介します。

 

RedHatなどではDistributionへの取り込みが行われ、OS標準の機能としてもつかえるようになってきましたが、ここではUbuntu向けにソースを入手して構成する手順をまとめています。

 

・Relax and Recoverと記載範囲

 

OSイメージを外部媒体に退避するためのOSSです。

クライアント/サーバー方式での構成も可能ですが、ここではバックアップ対象のサーバーにソフトウェアをインストールし、シンプルにシステムイメージと起動ISOを作る方法についてまとめます。

リストア時はサーバーをISOから起動することで、半自動化されたシステムの復元が行われます。ソフトウェア自体の詳細は、以下の末尾記載の公式のURLをご参照ください。

 

・バックアップの対象

ここでは、Minsky(S822LC for HPC)の内蔵ディスクにインストールされたOSイメージをNFS上の公開領域にバックアップします。

 

参考)検証時の構成概要

・システム装置:S822LC for HPC

・OS: Ubuntu 16.04 (ppc64le)

・DISK冗長化方法:Software RAID (RAID 1)

・LVM 使用する

・Relax & Recover 2.2

 

・導入

対象のUbuntu Server 上でソフトウェアの導入を行います。ソフトウェアはgithubからソースをダウンロードの後、コンパイルします。

 


$ git clone https://github.com/rear/rear.git

$ ls rear/
AUTHORS  COPYING  doc  etc  Makefile  packaging  README.adoc  usr
$ cd rear
$ make deb


* 環境によっては、makeの実行にパッケージ(devscripts/debhelper)の導入が必要です。

これは、apt-getコマンドで導入が可能です。

 


$ sudo apt-get install devscripts debhelper


 

コンパイルが正しく完了すると、ソースディレクトリのdist以下にdebパッケージが作成されます。


$ ls dist/rear_2.2-git.2362.2658745.master_ppc64el.deb
dist/rear_2.2-git.2362.2658745.master_ppc64el.deb


 

構成されたパッケージの導入を行います。

その際、rear自体の前提パッケージが存在しますので、導入されていないものがあれば導入します。



# apt-get install ethtool xorriso iproute isolinux dosfstools parted libisoburn1 libburn4 libisofs6 nfs-client portmap gawk attr keyutils nfs-common libsigsegv2 libjte1 libevent-2.0-5 libnfsidmap2 libtirpc1

# dpkg -i rear_2.2-git.2362.2658745.master_ppc64el.deb
(Reading database ... 105145 files and directories currently installed.)
Preparing to unpack rear_2.2-git.2362.2658745.master_ppc64el.deb ...
Unpacking rear (2.2-git.2362.2658745.master) over (2.2-git.2362.2658745.master) ...
Setting up rear (2.2-git.2362.2658745.master) ...
Processing triggers for man-db (2.7.5-1) ...
 


 

・設定

 

設定は、/etc/rear/local.confを編集します。

ここでは、nfsサーバーに対してバックアップを取得するための最小限の設定として以下を追記しました。



BACKUP=NETFS
BACKUP_OPTIONS="nfsvers=3,nolock"
BACKUP_URL=nfs://<nfsserverのIP>/<パス>


 

設定ファイルの記載は以下を参考にしています。

Configuration

https://github.com/rear/rear/blob/master/doc/user-guide/03-configuration.adoc

 

・バックアップの取得

 

設定が完了したらバックアップを取得します。

以下のコマンドで、バックアップのイメージと起動用のisoファイルがバックアップ先に作成されます。


$ sudo rear mkbackup -v
 

(nfsサーバー側)
$ ls -l
合計 2534100
-rw------- 1 root root        202  8月  8 12:22 2017 README
-rw------- 1 root root        302  8月  8 12:22 2017 VERSION
-rw------- 1 root root    8477919  8月  8 12:25 2017 backup.log
-rw------- 1 root root 2485875779  8月  8 12:25 2017 backup.tar.gz
-rw------- 1 root root  100050944  8月  8 12:22 2017 rear-ubuntu.iso
-rw------- 1 root root     492133  8月  8 12:22 2017 rear-ubuntu.log

 


 

*バックアップの実行時、起動イメージのtgzファイルは、一時的にバックアップを実行しているサーバーの/tmp以下に作成されます。

従って内蔵ディスク側にある程度の空き容量が必要になります。


・リストア


前の手順で生成されたrear-ubuntu.isoからサーバーを起動し、リストアを行います。

リストアは自動化されていますが、grubの再インストールは手動で行う必要があります。

 

なお、Minskyの場合、BMC(ベースボードマネジメントコントローラ)から、作成したisoファイルをサーバーにマウントさせることが可能です。

具体的な手順は以下のマニュアルをご参照ください。ここではこの手順の記載は省略します。

https://www.ibm.com/support/knowledgecenter/en/POWER8/p8eih/p8eih_bmc_consoleredirect.htm?pos=5

 

ログインプロンプトが表示されたら、rootなどのユーザーでログインします。(パスワード不要)


Relax-and-Recover 2.2-git.2362.2658745.master / 2017-08-03

Relax-and-Recover comes with ABSOLUTELY NO WARRANTY; for details see
the GNU General Public License at: http://www.gnu.org/licenses/gpl.html

Host s822lc-2 using Backup NETFS and Output ISO
Build date: Wed, 16 Aug 2017 17:11:27 +0900


Ubuntu 16.04.3 LTS s822lc-2 hvc0

s822lc-2 login: root



その後、以下のコマンドで復元を開始します。

初期RAMのインストールを促す旨のメッセージが表示され処理が終了します。



# rear recover
Restored 62893 MiB in 956 seconds [avg. 67367 KiB/sec]
Restoring finished.
Restore the Mountpoints (with permissions) from /var/lib/rear/recovery/mountpoint_permissions

:

---------------------------------------------------
|  IF YOU DO NOT INSTALL A BOOT LOADER MANUALLY,  |
|  THEN YOUR SYSTEM WILL NOT BE ABLE TO BOOT.     |
---------------------------------------------------

You can use 'chroot /mnt/local bash --login'
to change into the recovered system.
You should at least mount /proc in the recovered system
e.g. via 'mount -t proc none /mnt/local/proc'
before you change into the recovered system
and manually install a boot loader therein.


 


ファイルシステムは、/mnt/local以下にマウントされていますのでchrootし、grubの再インストールを行います。


# mount /dev -o bind /mnt/local/dev

# mount /sys -o bind /mnt/local/sys
# mount /proc -o bind /mnt/local/proc
# chroot /mnt/local/
# /bin/bash
# PATH=/usr/sbin:/usr/local/bin:/usr/sbin/:/usr/bin/:/sbin/:$PATH
# cd /boot

 

# fdisk -l /dev/sda
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F7FB3CCD-0E46-4905-B287-5B3DDF8C9720

 

Device     Start        End    Sectors   Size Type
/dev/sda1   2048      16383      14336     7M PowerPC PReP boot
/dev/sda2  16384 1953523711 1953507328 931.5G Linux RAID

 

# grub-install /dev/sda1
Installing for powerpc-ieee1275 platform.
Installation finished. No error reported.


 

サーバーをシャットダウンしメディアをとりはずしサーバーを起動します。

 

手順は以上です。

なお最後になりますが、ここでご紹介したシステムバックの方法は簡単な分、例えば静止点や世代管理などが限定された内容になっています。

商用製品のIBM Spectrum ProtectもPower System およびUbuntuへの対応をしておりますので、用途に合わせて適切に選択いただけばと思います。

 

参考)関連URL

 

-Relax-and-Recover

http://relax-and-recover.org/

 

-Developer Works Topic: Relax And Recover for Linux on Power

https://www.ibm.com/developerworks/community/forums/html/topic?id=13cba998-e3e5-4061-9c83-cc8667ad0d9a

 

-IBM Spectrum Protect Supported Operating Systems
http://www-01.ibm.com/support/docview.wss?uid=swg21243309#Linux%20on%20POWER%20LE

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

UID

ibm16169503