immauss / openvas

Containers for running the Greenbone Vulnerability Manager. Run as a single container with all services or separate single applications containers via docker-compose.
GNU Affero General Public License v3.0
354 stars 102 forks source link

recommend rebuild report_formats on DB restore #111

Closed ciscoqid closed 2 years ago

ciscoqid commented 2 years ago

This may be just a "me issue", but I recently launched a new container with a restore from our Secure Compliance container database (with appropriate tweaks for Postgres 13 -> 12). I found that report formatting was busted this weekend, requiring this command to be run:

su gvm -c "gvmd --rebuild-gvmd-data=report_formats"

I was thinking it might be a good idea to run that rebuild after the RESTORE=true sequence. Thoughts?

immauss commented 2 years ago

Thanks. That's an easy fix and a great idea. I'm curious, would you mind sharing the appropriate tweaks and maybe anything else you needed to do to move from the Secure Compliance container. I've noticed quite a few people making that move lately.

Thanks, Scott

ciscoqid commented 2 years ago

Sure, happy to help!

First I used the documented command to dump the original SCS database into a file. Since the current version of Postgres on the SCS container is 13, the CREATE DATABASE line must be replaced with the line from this container's due to incompatibility of the LOCALE option.

After that, I used this to load:

docker run -it -e NEWDB=false -e RESTORE=true -v pwd/db-backup-file.sql:/usr/lib/db-backup.sql --rm -v openvas:/data immauss/openvas

Note that the restore could be optimized a bit in the script to avoid loading a fresh database that is subsequently dropped, but it is not a huge issue.

The last issue I found was that this container uses HTTP not HTTPS (SCS uses HTTPS by default), which required we adjust our nginx upstream URL. I kept thinking there was something wrong with the load process until I opened access to the published port directly to test :).

immauss commented 2 years ago

@ciscoqid Thanks. I really appreciate the feedback. I should have some more time coming up here soon. I'll look into optimizing the restore, and I think defaulting to https is a good idea, I'm just worried about breaking backwards compatibility with things others have done already.

immauss commented 2 years ago

This should be int he post recent refresh now.

Thanks! -Scott