Introduction
The Chef Infra Server is a powerful configuration tool that stores cookbooks, policies and other metadata related to its registered nodes. Thus, managing the Chef Infra Server is an essential task. This includes setting up periodic backups, failure recovery, monitoring, server tuning and maintaining server log files. Let us discuss each of these in detail.

Backup and Restore
Periodic backups of Chef Infra Server help maintain a healthy configuration and availability of critical data during a restore operation. A backend data backup saves Chef Backend cluster data, and a server configuration backup saves Chef Infra Server configuration file data. Restore and backup are closely connected. Both have specific subcommands that can be used to carry out these operations.
Backup
Chef Infra Server data backups can be created using the backup subcommand. This command requires the installation of rsync on the Chef Infra Server before running the command. It also requires a chef-server-ctl reconfigure. Note that the backup subcommand must not be run in a configuration with an external PostgreSQL database.
Syntax:
chef-server-ctl backup
Upon running the backup command, it puts the initial backup as a tar.gz file in the /var/opt/chef-backup directory. The file can be moved to a new location for safekeeping. The command had five additional options.
-
-y, --yes: It specifies if the Chef Infra Server can go offline during tar.gz-based backups.
-
--pg-options: It passes additional options to PostgreSQL during backups.
-
-c, --config-only: This allows you to back up the Chef Infra Server configuration without backing up data.
-
-t, --timeout: It sets the maximum time to wait for shell commands. By default, the value is 600.
- -h, --help: It shows a guide to backup data.
Restore
We can restore Chef Infra Server data from a backup using the restore subcommand. It can also be used to add Chef Infra Server data to a newly-installed server. Similar to the backup subcommand, this command must not be run in a Chef Infra Server configuration that uses an external PostgreSQL database. It also requires a preinstalled rsync on the Chef Infra Server and a chef-server-ctl reconfigure before running the command.
A restore server has the same fully qualified domain name as the server that was backed up. If it has a different FQDN, the following steps must be carried out.
Step 1: Replace the FQDN in the /etc/opscode/chef-server.rb and the /etc/opscode/chef-server-running.json files.
Step 2: Delete the old SSL certificate, key and -ssl.conf file from /var/opt/opscode/nginx/ca.
Step 3: Update the /etc/chef/client.rb file to point to the new server FQDN in all clients.
Step 4: Run chef-server-ctl reconfigure.
Step 5: Run chef-server-ctl restore.
Syntax:
chef-server-ctl restore PATH_TO_BACKUP (options)
The restore subcommand has the following options:
-
-c, --cleanse: It removes all the data on the Chef Infra Server.
-
-d DIRECTORY, --staging-dir DIRECTORY: It specifies the path to an empty directory used for the restore process.
-
--pg-options: It is used to specify and pass additional PostgreSQL options during backups.
-
-t, --timeout: It sets the maximum time allowed to wait for shell commands. The default value is 600.
- -h, --help: It displayed the help message and a guide to using the command.
Backend Restore
Restoring a backend service creates a new cluster and a JSON secrets file that sets up communication between nodes. First, select one node and restore the backup on it using its IP address as the value in the following command.
chef-backend-ctl restore --publish_address my.company.ip.address /path/to/backup.tar.gz
The JSON secret file is located at /etc/chef-backend/chef-backend-secrets.json. Copy the file at tmp/chef-backend-secrets.json for each node. The join cluster subcommand can be used to establish communication inside the cluster.
chef-backend-ctl join-cluster --accept-license --yes --quiet IP_OF_LEADER_NODE --publish_address IP_OF_FOLLOWER_NODE -s /tmp/chef-backend-secrets.json
Front-end Restore
Step 1: Configuration for the front-end chef-server can be generated using the command.
chef-backend-ctl gen-server-config chefserver.internal > /tmp/chef-server.rb
Step 2: Restore the Chef Infra Server from the backed-up configuration generated by the new cluster.
chef-server-ctl restore /path/to/chef-server-backup.tar.gz
Step 3: Copy the generated config from step 1 to the front-end node and replace it with /etc/opscode/chef-server.rb. Reconfigure the save the changes.
chef-server-ctl reconfigure
Step 4: To repopulate the search index run the reindex command.
chef-server-ctl reindex --all






