chef / chef/chef-server

bug(chef-server-ctl): backup staging area is ignored by the Postgres dump logic

Open
#4,036 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Untriaged
Dominant language
Erlang
Stars
303
Forks
211
Avg merge
1d 8h
Merged PRs (30d)
5

Description

Chef Server Version

15.10.33 and previous

Platform Details
  • CentOS 8
  • 4 x vCPU / 8GB RAM
Configuration

Standalone

Scenario

As Chef Server admin I wish to take a backup via chef-server-ctl backup but the /tmp space is limited and cannot be extended, so I wish to use another directory.

The backup and restore logic has a number of issues related to the staging directory:

  1. For the DB dump is hardcoded to /tmp (or env TMPDIR)
  2. The --staging-dir/-d option appears as available in --help output but it is really not used in the backup logic, only in the restore.
  3. Even if the chef-server-ctl backup logic may pass the option backup_dir with the staging directory to chef_backup library, it is still ignored (hardcodes tmp_dir in many parts of the tar.rb backup strategy):
  1. The DB dump dir should be inside the staging dir and not completely independent
  2. There are some privilege/permission denied issues
Steps to Reproduce
  1. Run chef-server-ctl backup and observer the directories in the output
  2. Run with --staging-dir flag and see no changes
Example
# chef-server-ctl backup --staging-dir .
Locating rsync..
/bin/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: 0s, normally up
ok: down: oc_bifrost: 1s, normally up
ok: down: oc_id: 1s, normally up
ok: down: opensearch: 1s, normally up
ok: down: opscode-erchef: 1s, normally up
ok: down: redis_lb: 0s, normally up
Dumping Postgresql database to /tmp/chef_backup20250721-4112-qhl12s/chef_backup-2025-07-21-12-07-37.sql
could not change directory to "/tmp/d20250721-4112-q9bxx9": Permission denied
ok: down: postgresql: 0s, normally up
Writing backup manifest
Creating backup tarball
/opt/opscode/embedded/lib/ruby/gems/3.0.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:187: warning: conflicting chdir during another chdir block
tar: Eliminando la `/' inicial de los nombres
tar: Eliminando la `/' inicial de los objetivos de los enlaces
Bringing up the Chef Server
ok: run: bookshelf: (pid 4186) 0s
ok: run: nginx: (pid 4286) 0s
ok: run: oc_bifrost: (pid 4294) 0s
ok: run: oc_id: (pid 4394) 0s
ok: run: opensearch: (pid 4401) 0s
ok: run: opscode-erchef: (pid 4511) 1s
ok: run: postgresql: (pid 4624) 0s
ok: run: redis_lb: (pid 4679) 0s
Exporting tarball to /var/opt/chef-backup
Cleaning up /tmp/chef_backup20250721-4112-qhl12s
Backup Complete!
  1. Directory /tmp/d20250721-4112-q9bxx9 is attempted to be used by the backup logic and
  2. Directory /tmp/chef_backup20250721-4112-qhl12s is used for DB dump regardless of the --staging-dir value and the previous /tmp/d20250721-4112-q9bxx9 directory
Expected Result

The staging dir can be changed in the command line and the DB dump directory is nested into it.

Actual Restult

Flag --staging-dir is ignored and the staging area is in two different directories under /tmp.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the chef-server-ctl backup handling and lib/chef_backup/strategy/backup/tar.rb around lines 48-65, then trace how --staging-dir/-d and backup_dir reach the PostgreSQL dump logic. Reproduce with chef-server-ctl backup --staging-dir and verify that the dump directory is nested under the selected staging directory without the reported permission failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, ruby
Domain
database, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.