Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

ChefTips: Chef Serverのバックアップについて

More than 1 year has passed since last update.


Chef Server では、サーバー・コマンドによるバックアップ機能が提供されています。
chef-server-ctl コマンドのbackupサブコマンドを使用します。





chef-server-ctl backup 実行の前提

Chef Serverが導入されているOSにrsyncが導入されていることが必要です。
また、前提ではありませんが、backup実行前に chef-server-ctl reconfigure を実行することが推奨されています。


chef-server-ctl reconfigure の実行例です。

  • rootで実行します
  • Chef Server Reconfigured! と表示されれば完了です。

なお、chef-server.rbに何も変更を加えていなくても、下記例のように"resources updated"と表示されますが、問題ありません。

# 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 backup の実行例

  • rootで実行します
# chef-server-ctl backup
Locating rsync..
Starting Chef Server backup
WARNING:  Offline backup mode must stop your Chef server before continuing.  You can skip this message by passing a "--yes" argument. Do you wish to proceed? (y/N):             <- サーバー・プロセスが停止されることを受け入れる(yを入力)
Bringing down the Chef Server                                                       <- サーバー・プロセスの停止処理が開始される
ok: down: bookshelf: 0s, normally up
ok: down: nginx: 1s, normally up
ok: down: oc_bifrost: 0s, 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: 0s, normally up
ok: down: rabbitmq: 0s, normally up
ok: down: redis_lb: 1s, normally up
Dumping Postgresql database to /tmp/chef_backup20170912-14975-avvp8n/chef_backup-2017-09-12-12-29-48.sql
could not change directory to "/tmp/d20170912-14975-16go2dp"
ok: down: postgresql: 1s, normally up
Writing backup manifest
Creating backup tarball
/opt/opscode/embedded/lib/ruby/gems/2.2.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:183: warning: conflicting chdir during another chdir block
tar: Removing leading `/' from member names
Bringing up the Chef Server                                                      <- サーバー・プロセスの起動処理が開始される
ok: run: bookshelf: (pid 15433) 0s
ok: run: nginx: (pid 15496) 0s
ok: run: oc_bifrost: (pid 15511) 1s
ok: run: oc_id: (pid 15566) 0s
ok: run: opscode-chef-mover: (pid 15579) 0s
ok: run: opscode-erchef: (pid 15626) 1s
ok: run: opscode-expander: (pid 15658) 0s
ok: run: opscode-solr4: (pid 15684) 1s
ok: run: postgresql: (pid 15719) 0s
ok: run: rabbitmq: (pid 15773) 0s
ok: run: redis_lb: (pid 16345) 1s
Exporting tarball to /var/opt/chef-backup
Cleaning up /tmp/chef_backup20170912-14975-avvp8n
Backup Complete!


/var/opt/chef-backup に.tgzファイルが生成される。

# ll /var/opt/chef-backup/
total 35148
-rw-r--r--. 1 root root 35989965 Sep 12 12:32 chef-backup-2017-09-12-12-29-48.tgz


Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away