Backup and Restore
This guide describes the general workflow how to backup and restore an OpenNMS instance.
Record you setup
Linux distribution package management should automatically install the required components like PostgreSQL, Jetty, RRD etc and will take care of version and dependencies.
But it’s always good to know, which versions you have running.
root@opennms:~$ apt search opennms-server | grep installed WARNING: apt does not have a stable CLI interface. Use with caution in scripts. opennms-db/opennms-22,opennms-22,now 22.0.4-1 all [installed,automatic] opennms-server/opennms-22,opennms-22,now 22.0.4-1 all [installed,automatic]
root@opennms:~$ java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
root@opennms:~$ psql --version psql (PostgreSQL) 9.5.14
pg_dump of the database.
It can be done while PostgreSQL is running.
root@opennms:~$ runuser -l postgres -c 'pg_dump -W -U opennms -Fc -f $SOME_DIR/opennms.pgsql.gz opennms' Password:
All configuration is stored in
It can easily be backed up using tar.
tar -cvzf $SOME_DIR/opennms-etc.tar.gz $OPENNMS_HOME/etc/`
OpenNMS RRD files are stored in
$OPENNMS_HOME/share/rrd and can also easily backed up using tar:
tar cvfz $SOME_DIR/opennmsrrd.tar.gz $OPENNMS_HOME/share/rrd/
Follow the official install guide.
Special attention if you use older version of OpenNMS!
Make sure OpenNMS is not running while restoring the data.
systemctl start postgresql.service
su as the postgres user and delete the current OpenNMS database
As postgres user, create a new clean db owned by the opennms user
createdb -O opennms opennms
As postgres user, restore the DB:
pg_restore -U opennms -Fc -d opennms /path/to/db_dump_file
To reduce the amount of time used to perform the restore, add the
-j NUM option to the command with NUM being the number of parallel jobs used to perform the restore (the number of cores in your server would be a good starting point for the NUM value):
pg_restore -U opennms -Fc -j 24 -d opennms /path/to/db_dump_file
The restore should produce no errors. If there are errors, examine them and fix at this point and restart the Postgresql service.
- Stop OpenNMS and delete the the content of the RRD folder
rm -rf $OPENNMS_HOME/share/rrd/*
- Extract the backup into RRD folder
tar -xzf $SOME_DIR/opennms-rrd.tar.gz -C $OPENNMS_HOME/share/rrd
- Stop OpenNMS and delete the the content of the etc folder
rm -rf $OPENNMS_HOME/etc/*
- Extract the backup into etc folder
tar -xzf $SOME_DIR/opennms-etc.tar.gz -C $OPENNMS_HOME/etc
There is a community driven GitHub repository with backup script examples. Feel free to use or improve them.
Those are not maintained and could be out of date.