Foreman_maintain install/walkthrough?

Running foreman 1.16 on CentOS 7.

Installed: rubygem-foreman_maintain-0.2.4-1.el7.noarch using the 1.19 foreman yum repo.

Is there a walkthrough for install and basic use of foreman_maintain? I found the site

And while I got the yum package installed it didn’t really cover much. I couldn’t get the backup portion to work and it could be because I’ve installed the wrong tool version.

Do you have to have the same version of foreman_maintain as your foreman install?

If not while just running a simple :
foreman-maintain backup offline /tmp/backups

I get a failure that doesn’t really give me a clue whats missing.

Backup config files:
- Collecting config files to backup                                   [FAIL]
undefined method `[]' for nil:NilClass

The output from logfile is this:
D, [2018-11-12 22:09:54+0000 #95461] DEBUG – : foreman proxy content module detected: foreman_proxy_content
undefined method []' for nil:NilClassE, [2018-11-12 22:09:54+0000 #95461] ERROR -- : undefined method’ for nil:NilClass (NoMethodError)

I tried command line option:
Resolve the failed steps and rerun the command. In case the failures are false positives, use --whitelist="backup-config-files"

foreman-maintain backup offline /tmp/backups --whitelist="backup-config-files"

But this comes back with ERROR: too many arguments

This is a clean foreman host just installed running 1.16. We are planning to upgrade it to 1.19 (or 1.20 if its done by the end of this process) to determine how the whole process works to eventually run it on our production host.

Turned up logging and when running and upgrade list-versions and I see a load of entries like this.

D, [2018-11-13 02:38:29+0000 #110760] DEBUG – : Running command rpm -q foreman with stdin nil
D, [2018-11-13 02:38:29+0000 #110760] DEBUG – : output of the command:

#. rpm -q foreman

Not sure what’s up.

Hello Mike,

Currently, foreman-maintain does not have any upgrade scenarios for upstream versions of Foreman. That’s why it is giving empty result for upgrade command. “Upstream Foreman upgrade scenario” feature request is still a work in progress. You can track the PR here PR-230.

@mbacovsky, for backup/restore do you have any pointers? or I think it’s better to wait for this above PR to get merged into master so that users can experience the full flow cycle of backup-upgrade-restore.

@Mike, please check this link, one of the demo video which gives some internals of foreman-maintain.

No, but it is better to have supported Foreman version as it probably gone through some testing.

This sounds like a bug. Would you mind creating a new issue in our tracker with the description you have here and at least the backtrace from the log you have. This way we can make sure it is fixed for new Foreman releases and you can track the progress.

This error is caused by swapping the options and the final argument in the CLI. With correct order it should work:

foreman-maintain backup offline --whitelist="backup-config-files" /tmp/backups

Let us know if it didn’t.

As @kgaikwad explained we do not support upstream upgrade scenarios yet. I have it on my TODO for next few weeks so keep watching the issue she linked or this list for updates.

Can you explain what you mean “upstream upgrade” ? I’m not entirely clear what it means.

That got it to backup minus the config files, thanks!

1 Like

Can you explain what you mean “upstream upgrade” ? I’m not entirely clear what it means.

My Apologies! Here, I wanted to refer as Foreman upgrade.
Using foreman-maintain upgrade command, user will able to upgrade their foreman instances. That is currently under work in progress.

1 Like

Oh, I was under the impression is already managed upgrades. Woops! Guess I’ll have to do it by hand :frowning:

Just wanted to confirm that I’m also experiencing this bug as well with the 1.20.0-RC2 release:

Backup config files:
- Collecting config files to backup                                   [FAIL]
undefined method `[]' for nil:NilClass

Appending --whitelist="backup-config-files" resolves the issue.

I just noticed this in the docs:

Supported systems

Backup and Restore in Foreman Maintain works on the following:

    Katello (>3.0)
    Foreman Proxy with Content (>3.0)

Backup and Restore support for standalone Foreman is currently in development.

I’m not using Katello or Foreman Proxy with Content. Perhaps, that would be one possible explanation for that error.

p.s. Any idea how reliable the backups are for a standalone Foreman installation?

Its a bit counter-intuitive, but foreman-maintain backup and restore was written for Katello first. Katello is harder to backup than Foreman due to the multiple services and database it uses so it makes sense to have a tool manage it.

We definitely would like to support backing up Foreman and have it run without workarounds like the whitelisting of steps mentioned above so please do file any bugs if they have not been filed yet.

I do think there are rake tasks like foreman-rake db:dump to backup Foreman currently, you may find these helpful

1 Like

Hi , I have upgraded from foreman 1.20.1 to 1.22 but getting same error while running the foreman-maintain backup offline /tmp/backups
Backup config files:

  • Collecting config files to backup [FAIL]
    undefined method `’ for nil:NilClass

just want to understand if we use whitelist what and all files will be missed out while doing restore? its working if i use whitelist option.

Having the same, nil:NilClass error when it comes to backing up config. I saw there was some advice around using the white list option --whitelist="backup-config-files" to stop the config being backed up.

While testing the restore process, this also throws errors which point to using additional whitelist options. I can’t seem to get this working in a coherent way, so I’m not sure how reliable this would be as a work around.

It is not a reliable workaround to do --whitelist="backup-config-files".

nil:NilClass issue has been fixed in foreman-maintain and will be available in next version of foreman-maintain package.

Meanwhile, if needed you can patch the file foreman_proxy.rb as per the below-given PR.


Issue - Bug #30166: Backup fails with undefined method `[]' for nil:NilClass - Foreman Maintain - Foreman
PR -

Hi Suraj

Thanks for the suggestion, it did notice that fix from another forum post and gave it a go, but for some reason it didn’t work for me. Can’t quite remember the error it gave me.

I ended up downloading the foreman-maintain git repo, I tried a few tagged version but could only backup while on the master branch. This still doesn’t work with the restore function but at least backs up the config files. I’ll wait for the new version to come through yum and hopefully that will fix things for me.