Migrate from PPA mrazavi to GSE

Hello!
PPA mrazavi’s is not being developed, and i will have to migrate to the GSE version. I exported data to PostgreSQL using the “gvm-migrate-to-postgres” utility, but the database structure is different and the export does not work. How to export all settings of gvm-10 mrazavi’s PPA to GSE? What are other tools for exporting settings?

Отвечаю сам себе.

Проблема: при миграции базы sqlite->PostgreSQL , используя скрипт из PPA:mrazavi “gvm-migrate-to-postgres”, получаю ошибку:

root@openvas01:/var/log/gvm# gvm-migrate-to-postgres
<30>Oct  2 17:35:53 gvm-migrate-to-postgres: Checking SQLite3 database.
<31>Oct  2 17:35:53 gvm-migrate-to-postgres: SQLite: DROP INDEX report_hosts_by_host;
<31>Oct  2 17:35:53 gvm-migrate-to-postgres: SQLite: CREATE INDEX report_hosts_by_host ON report_hosts (host);
<31>Oct  2 17:35:53 gvm-migrate-to-postgres: SQLite: PRAGMA integrity_check;
<31>Oct  2 17:35:53 gvm-migrate-to-postgres: PG: SELECT EXISTS (SELECT table_name FROM information_schema.tables WHERE table_catalog = 'gvmd' AND table_schema = 'public' AND table_name = 'meta') ::integer;
<29>Oct  2 17:35:53 gvm-migrate-to-postgres: Database version not supported:

1. Смотрим код скрипта, вызывающий ошибку - выполняется сверка версии базы. Проверяю этот селект руками:

sqlite3 /var/lib/gvm/gvmd/gvmd.db
sqlite> select value from meta where name = 'database_version';
205

2. Ищу в коде 205 версию :
grep "TABLES_205" /usr/sbin/gvm-migrate-to-postgres

Такой нет. Заканчивается на TABLES_188 - скрипт из PPA старой версии.

3. Беру новый скрипт, и адаптирую под PPA:

wget -O gvm-migrate-to-postgres.sh https://raw.githubusercontent.com/greenbone/gvmd/master/tools/gvm-migrate-to-postgres.in
nano gvm-migrate-to-postgres.sh

… меняю в разделе SETTINGS…

[ -r @GVM_SYSCONF_DIR@/migrate-to-postgres.conf ] && . @GVM_SYSCONF_DIR@/migrate-to-postgres.conf

if [ -z “$SQLITE_DB_DIR” ]; then
SQLITE_DB_DIR=“@GVMD_STATE_DIR@”
fi

на

[ -r /etc/gvm/migrate-to-postgres.conf ] && . /etc/gvm/migrate-to-postgres.conf

if [ -z "$SQLITE_DB_DIR" ]; then
  SQLITE_DB_DIR="/var/lib/gvm/gvmd"
fi

4. Перед запуском скрипта создаю базу (gvmd/doc/postgres-HOWTO at v8.0.0 · greenbone/gvmd · GitHub)

sudo -u postgres sh
createuser -DRS gvmduser
createuser -DRS root
createdb -O gvmduser gvmd
psql gvmd
create role dba with superuser noinherit;
grant dba to gvmduser;
grant dba to root;
create extension "uuid-ossp";
grant all privileges on all tables in schema public to root;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO root;
ALTER USER root with password 'mypass';
ALTER USER gvmduser with password 'mypass';

5. Запускаю скрипт
sh gvm-migrate-to-postgres.sh

Все хорошо. Получили Базу с данными из PPA. Теперь можно устанавливать из исходников GVM-10 и подключать созданную базу.

He told me he would recompile every new release. Did you hear otherwise?

Hello @hildeb ! Earlier, he regularly updated. But now, unfortunately, he has not updated the PPA after the beta-version.

He told me he would keep in sync with the 6 monthly upstream releases…
We’re talking about:
https://launchpad.net/~mrazavi/+archive/ubuntu/gvm

1 Like

Then this explains the update delay. Latest PPA update was be 5 months ago. Ralf, thanks for the feedback!

1 Like