Create Backup from Greenbone CE Container

Hi guys,

I am running the Greenbone Community Edition from docker containers and I would like to create a backup of the whole system.
To do this, I followed this post (Backup in OpenVAS 22.4.0) where it says following:

- The SQL dump (in whatever form, binary, sql statements, CSV, …) of the gvmd database of your postgresql cluster
- The VTs in the /var/lib/openvas directory (if the standard directory layout is used)
- The other feed data in /var/lib/gvm (if the standard directory layout is used)
- The logs in /var/logs/gvm (if the standard directory layout is used)
- Possible configuration files in /etc/gvm (if the standard directory layout is used)
- The GPG keychain in /etc/openvas/gnupg (if the standard directory layout is used)

Everything worked and I copied the data from the corresponding containers, although I noticed that custom created targets, port-lists, schedules, tasks, etc. are not present. They are visible in the web interface, but when investigating the file system and database dump the configs are not there. Looking inside the gvmd container in data-objects I can only see the default objects.
This problem became even more apparent when I set up a new test system and restored the backup, the custom port-lists, targets, etc. are not present.

Could someone tell me the exact location of the custom created objects so I can include them in my backup, or tell me what I am missing here?

Best regard and thank you for your help.

Hey,

After a few hours break I tried again and it seems to work now. Maybe I messed something up when creating the database dump.
If someone has a similar problem and is interested in how I backup and restore the greenbone db, I list my procedure below. Also, in case I do something in a awkward way, you can also let me know.

Backup:
- Create a db dump from the pg-gvm container  

docker exec -i -u postgres greenbone-community-edition-pg-gvm-1 pg_dump gvmd -F c -f /any/dir/file.sql

- Copy the db dump from the container to the local fs

docker cp greenbone-community-edition-pg-gvm-1:/source/dir/file.sql /target/dir/

Restore:
- Start the greenbone community edition containers
- Have the db dump on the local FS and run pg_restore to restore the db 

docker exec -i greenbone-community-edition-pg-gvm-1 pg_restore -U gvmd -c -v -d gvmd < /source/dir/file.sql

- (the -c is important here because greenbone already creates a db when starting 
  up and -c will clear the existing db and fully restore the db from the dump.  
  Without -c it won't work, but of course you can also drop the db manually 
  before restoring.)
1 Like