概要
本文書では Chef Server のリストアについて解説します。
- Chef Server には Chef Server設定のリストア機能が提供されています。
- リストア機能を使うと、既存 もしくは 新規の Chef Serverに対して設定がリストアすることができます。
- バックアップ機能については こちら[https://qiita.com/kentarok/items/61af5ba7eae836b56b2a] を参照ください。
Syntax
$ chef-server-ctl restore PATH_TO_BACKUP (options)
Examples
$ chef-server-ctl restore /path/to/tar/archive.tar.gz
公式マニュアル
リストア実行の前提
- Chef Serverが導入されていること
- Chef Serverが導入されているOSにrsyncが導入されていること
- backup実行前に chef-server-ctl reconfigure を実行すること
chef-server-ctl reconfigure 実行例
※rootで実行します。
※「Chef Server Reconfigured!」と表示されれば完了です。
なお、chef-server.rbに何も変更を加えていなくても、下記例のように"resources updated"と表示されますが、問題ありません。
[root@sjchefs01 ~]# chef-server-ctl reconfigure
Starting Chef Client, version 12.19.36
resolving cookbooks for run list: ["private-chef::default"]
Synchronizing Cookbooks:
- enterprise (0.10.1)
- private-chef (0.1.0)
- apt (2.9.2)
- yum (3.13.0)
- openssl (7.0.1)
- runit (1.6.0)
- packagecloud (0.3.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: private-chef::default
* directory[/etc/opscode] action create (up to date)
* directory[/etc/opscode/logrotate.d] action create (up to date)
Converging 289 resources
* link[/usr/bin/private-chef-ctl] action create (up to date)
* link[/usr/bin/chef-server-ctl] action create (up to date)
* directory[/etc/opscode] action nothing (skipped due to action :nothing)
* directory[/etc/opscode/logrotate.d] action nothing (skipped due to action :nothing)
* log[opscode_webui deprecation notice] action write (skipped due to only_if)
~中略~
Chef Client finished, 39/435 resources updated in 44 seconds
Chef Server Reconfigured!
リストアの実行
- chef-server-ctl restore コマンドで実行します
- リストア後、chef-server-ctl reconfigure コマンドも実行します
※rootで実行します。
※「Restoration Completed!」と表示されれば完了です。
[root@sjchefs01 ~]# chef-server-ctl restore /tmp/chef-backup-2017-09-14-19-19-47.tgz
Locating rsync..
/bin/rsync
Expanding tarball: /tmp/chef-backup-2017-09-14-19-19-47.tgz
Restoring Chef Server from backup
Cleaning up any old files
*******************************************************************
* * * * * * * * * * * STOP AND READ * * * * * * * * * *
*******************************************************************
This command will delete *all* local configuration, log, and
variable data associated with Chef Server.
You have 60 seconds to hit CTRL-C before configuration,
logs, and local data for this application are permanently
deleted.
*******************************************************************
ok: down: bookshelf: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: oc_bifrost: 1s, normally up
ok: down: oc_id: 0s, normally up
ok: down: opscode-chef-mover: 0s, normally up
ok: down: opscode-erchef: 0s, normally up
ok: down: opscode-expander: 0s, normally up
ok: down: opscode-solr4: 1s, normally up
ok: down: postgresql: 0s, normally up
ok: down: rabbitmq: 0s, normally up
ok: down: redis_lb: 1s, normally up
bookshelf disabled, not stopping
nginx disabled, not stopping
oc_bifrost disabled, not stopping
oc_id disabled, not stopping
opscode-chef-mover disabled, not stopping
opscode-erchef disabled, not stopping
opscode-expander disabled, not stopping
opscode-solr4 disabled, not stopping
postgresql disabled, not stopping
rabbitmq disabled, not stopping
redis_lb disabled, not stopping
Terminating processes running under application users. This will take a few seconds.
~中略~
You are now connected to database "template1" as user "opscode-pgsql".
SET
SET
SET
SET
SET
SET
SET
SET
SET
COMMENT
CREATE EXTENSION
COMMENT
Bringing up the Chef Server
ok: run: bookshelf: (pid 27181) 55s
ok: run: nginx: (pid 27056) 63s
ok: run: oc_bifrost: (pid 26956) 69s
ok: run: oc_id: (pid 27046) 69s
ok: run: opscode-chef-mover: (pid 22799) 196s
ok: run: opscode-erchef: (pid 27233) 66s
ok: run: opscode-expander: (pid 27089) 71s
ok: run: opscode-solr4: (pid 27069) 75s
ok: run: postgresql: (pid 22430) 223s
ok: run: rabbitmq: (pid 27719) 44s
ok: run: redis_lb: (pid 22906) 211s
Cleaning up /tmp/chef_backup20170914-21790-13h11li
Restoration Completed!
[root@sjchefs01 ~]# chef-server-ctl reconfigure
(省略)
補足
Chef Serverリストア後、Chef Workstation から knife コマンド発行した際に
ERROR: SSL Validation failure connecting to host:〜
が表示された場合は、以下のコマンドを実行してください。リストア後の Chef Server自己署名書を有効化します。
knife ssl fetch
以下の記事も是非ご参照くださいませ
ChefTips: Chef Serverバックアップ・リストア時の考慮点