Skip to content

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

@mauroseb

Description

@mauroseb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UntriagedAn issue that has yet to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions