Problem: foreman-maintain backup
does not function on CentOS8
Expected outcome: A clean run of the foreman-maintain backup
command
Foreman and Proxy versions: 2.1.0rc*
Foreman and Proxy plugin versions: 2.1.0rc*
Distribution and version: CentOS 8.2
Other relevant data:
While I realize the documentation states that you need Katello (Content Management) installed to backup the foreman instance, that seems odd to me, as there is data to be backed up in a generic foreman instance, so I pushed onwards.
I tried (as root):
foreman-maintain backup offline --skip-pulp-content --features all --include-db-dumps /tmp/backups
...snipped...
--------------------------------------------------------------------------------
Backup config files: [FAIL]
undefined method `[]' for nil:NilClass
--------------------------------------------------------------------------------
That failed, this has been brought up in other support posts without any one answering! Example: Backup-Restore Strategy in Foreman - In my testing, it also fails on CentOS 7.
So lets whitelist it as suggested and move on:
foreman-maintain backup offline --whitelist="backup-config-files" --skip-pulp-content --features all --include-db-dumps /tmp/backups
...snipped...
--------------------------------------------------------------------------------
Backup config files: [SKIPPED]
--------------------------------------------------------------------------------
Backup Foreman DB offline:
- Collecting data from /var/opt/rh/rh-postgresql12/lib/pgsql/data/ [FAIL]
No such file or directory @ dir_chdir - /var/opt/rh/rh-postgresql12/lib/pgsql/data/
--------------------------------------------------------------------------------
That doesn’t look good, and in fact it is a hard-coded database location for foreman >= 2.0, which is valid for CentOS 7, but not valid for CentOS 8. The following shows some details and the problematic code:
# dnf list installed | grep maintain
rubygem-foreman_maintain.noarch 1:0.6.5-1.el8 @foreman
# ps -ef | grep postmaster
postgres ...snipped... /usr/bin/postmaster -D /var/lib/pgsql/data
# pwd
/usr/share/gems/gems/foreman_maintain-0.6.5
# grep -r -C 5 /var/opt/rh
...snipped...
definitions/features/foreman_database.rb- def config_files
definitions/features/foreman_database.rb- if check_min_version('foreman', '2.0')
definitions/features/foreman_database.rb: ['/var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf']
definitions/features/foreman_database.rb- else
definitions/features/foreman_database.rb- ['/var/lib/pgsql/data/postgresql.conf']
definitions/features/foreman_database.rb- end
definitions/features/foreman_database.rb- end
definitions/features/foreman_database.rb-
--
lib/foreman_maintain/concerns/base_database.rb-module ForemanMaintain
lib/foreman_maintain/concerns/base_database.rb- module Concerns
lib/foreman_maintain/concerns/base_database.rb- module BaseDatabase
lib/foreman_maintain/concerns/base_database.rb- def data_dir
lib/foreman_maintain/concerns/base_database.rb- if check_min_version('foreman', '2.0')
lib/foreman_maintain/concerns/base_database.rb: '/var/opt/rh/rh-postgresql12/lib/pgsql/data/'
lib/foreman_maintain/concerns/base_database.rb- else
lib/foreman_maintain/concerns/base_database.rb- '/var/lib/pgsql/data/'
lib/foreman_maintain/concerns/base_database.rb- end
lib/foreman_maintain/concerns/base_database.rb- end
lib/foreman_maintain/concerns/base_database.rb-
As a new foreman user, the inability to backup a basic foreman instance (let alone, restore it), does not seem great given that foreman-maintain
is an installed command by default. And while I ignored a prerequisite, surely backing up a foreman+smart-proxy instance (c.f. foreman+smart-proxy+katello+pulp instance), should be a subset of the later. This was all done on the same CentOS 8 VM documented in my previous post: Problem with Foreman 2.1rc2 with Remote Execution on CentOS 8 - #33 by illumino
Is a basic backup/restore mechanism for generic foreman instances in the works? Surely it must be simplier or a subset of the +Katello+Pulp configuration.
PS: The database backup did complete on CentOS 7 and restart foreman. But as stated above the config files backup failed!