LoginSignup
2
1

AWS Backupで取得したバックアップからEBS/RDS/S3を復元してみた

Posted at

はじめに

お疲れ様です。yuki_inkです。
以下の記事の続きとして、取得したバックアップからの復元をやってみます。

前の記事で、AWS Backupで取得したバックアップは、以下2通りのやり方で確認できました。

  1. AWS Backupの画面から「復旧ポイント」として確認
  2. 各サービスの画面上で、スナップショットとして確認(EBS・RDS)

であるならば、復元も2通りのやり方でできるのでは? と考え、やってみました。

事前準備

EBS

セッションマネージャーでEC2「test-1」に接続し、/tmp 配下に bk_test というファイルを作成しました。
image.png

RDS

まず、デフォルトで存在するデータベースの一覧を表示します。

postgres=> \list
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 rdsadmin  | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | rdsadmin=CTc/rdsadmin+
           |          |          |             |             |            |                 | rdstopmgr=Tc/rdsadmin
 template0 | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/rdsadmin          +
           |          |          |             |             |            |                 | rdsadmin=CTc/rdsadmin
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
(4 rows)

そこに、bk_test というデータベースを作成しました。

postgres=> CREATE DATABASE bk_test;
CREATE DATABASE

postgres=> \list
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 bk_test   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 rdsadmin  | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | rdsadmin=CTc/rdsadmin+
           |          |          |             |             |            |                 | rdstopmgr=Tc/rdsadmin
 template0 | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/rdsadmin          +
           |          |          |             |             |            |                 | rdsadmin=CTc/rdsadmin
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
(5 rows)

S3

S3にもともと置いていた test01.txt を更新し、新しいバージョンをアップロードします。
image.png

image.png

AWS Backupの画面からの復元

バックアップボールトの画面から復旧ポイントが確認でき、そこから復元もできるのですが、ちょっとごちゃごちゃして見づらいので、今回は「保護されたリソース」の画面から復元していきます。

▼ バックアップボールトの画面(復旧ポイント)
image.png

▼「保護されたリソース」の画面
image.png
各リソースごとに復旧ポイントを示してくれます。
image.png

EBS

復元したい時点の「復旧ポイント」を選択し、「復元」ボタンをクリック。
image.png

各パラメータを埋めていきます。
image.png

完了!
image.png

新しいEBSボリュームができていました。
※ボリュームのサイズ間違えた…復元画面でもともとのサイズをデフォルトで表示してほしい💦
image.png

EC2「test-1」のルートボリュームを新しい方に付け替えて、インスタンスを起動。
/tmp 配下を確認すると、先ほど作成したファイルは表示されず、問題なく切り戻しできたようです。
image.png

RDS

復元したい時点の「復旧ポイント」を選択し、「復元」ボタンをクリック。
image.png

各パラメータを埋めていきます。
RDSの画面からリストアする雰囲気とほぼ一緒ですね。
image.png
image.png

完了!
image.png

RDSの画面からも、新しいインスタンスが確認できました。
image.png

「database-1-bk」に接続し、存在するデータベースの一覧を表示すると、先ほど作成した bk_test は表示されませんでした。
問題なく切り戻しできたようです。

postgres=> \list
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 rdsadmin  | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | rdsadmin=CTc/rdsadmin+
           |          |          |             |             |            |                 | rdstopmgr=Tc/rdsadmin
 template0 | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/rdsadmin          +
           |          |          |             |             |            |                 | rdsadmin=CTc/rdsadmin
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
(4 rows)

S3

復元したい時点の「復旧ポイント」を選択し、「復元」ボタンをクリック。
image.png

各パラメータを埋めていきます。
image.png

この時、使用するIAMロールに AWSBackupServiceRolePolicyForS3Restore が付与されていることを確認しておきましょう。
image.png

「バックアップを復元」ボタンをクリックすると、復元ジョブが走り始めます。
image.png

おや…?
image.png

対象のS3バケットのACL有効化を行わないといけないようです。

ACL有効化を実施して再度「バックアップを復元」してみます。
image.png

image.png

無事完了しました!よかった!
image.png

あれ、特に復元前と変わっていないんだが…?
image.png

それならばと、オブジェクトをすべて(バージョンを含めて)削除してみました。
image.png

再度「バックアップを復元」すると、なんと、先ほど消したオブジェクトが復活している!!
image.png

S3の復旧ポイントへの復元は、「その断面に戻す」というよりかは、「その断面に存在したオブジェクト(バージョン)を復元する」というニュアンスのほうが正しそうです。
誤って消してしまったファイルを戻すときに便利そう。

各サービスの画面からの復元

EBS

以前のスナップショットからボリューム「test1-bk」を作成。
image.png

image.png

EC2「test-1」のルートボリュームを「test1-bk」に付け替えて、インスタンスを起動。
/tmp 配下を確認すると、先ほど作成したファイルは表示されず、問題なく切り戻しできたようです。
image.png

RDS

以前のスナップショットから新しいインスタンス「database-1-bk」を作成します。
スナップショットは「バックアップサービス」タブの中に表示されます。
image.png

「database-1-bk」に接続し、存在するデータベースの一覧を表示すると、先ほど作成した bk_test は表示されませんでした。
問題なく切り戻しできたようです。

postgres=> \list
                                                 List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 rdsadmin  | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | rdsadmin=CTc/rdsadmin+
           |          |          |             |             |            |                 | rdstopmgr=Tc/rdsadmin
 template0 | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/rdsadmin          +
           |          |          |             |             |            |                 | rdsadmin=CTc/rdsadmin
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/postgres          +
           |          |          |             |             |            |                 | postgres=CTc/postgres
(4 rows)

S3

S3の画面から、オブジェクトを過去のバージョンに切り戻す/過去のバージョンのファイルを復元するという操作はできず、過去のバージョンのファイルをダウンロードすることができるというだけのようです。
そのダウンロードしたファイルを再度S3バケットにアップロードし、バージョンを更新することで、「切り戻し」という形になります。

せっかくなので、旧バージョンを選択してダウンロードするところだけやってみました。
image.png

終わりに

前回に引き続き、S3のところで何度か躓いてしまいました…

EBSとRDSの復元に関しては、AWS Backupの画面からも各サービスの画面からもできるということが分かりました。
今まで普通にスナップショットでバックアップを取ってきたという方にとっては、慣れたやり方で復元できるのはうれしいですね!

次回はボールトロック機能について検証してみたいと思います。
最後までお目通しいただき、ありがとうございました。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1