5.2.8.1. ON Core Backup

As a default configuration, all the ON Core servers have a backup script opennac_backup.sh, scheduled to run every day at 23:26.

Below, is the snippet of the cron configuration:

[root@opennac ~]# cat /etc/cron.d/opennac-backup
26 23 * * * root /usr/share/opennac/utils/backup/opennac_backup.sh > /dev/null 2>&1

As a default behavior, the generated backup tarballs are stored in /backup:

[root@opennac ~]# ls -l /backup/
-rw------- 1 root root 161149892 Feb 20 23:26 opennac-opennac.tpl-20180220_232601.tgz
-rw------- 1 root root 161098842 Feb 21 23:26 opennac-opennac.tpl-20180221_232601.tgz
-rw------- 1 root root 159619610 Feb 22 23:26 opennac-opennac.tpl-20180222_232601.tgz
-rw------- 1 root root 159843893 Feb 23 23:26 opennac-opennac.tpl-20180223_232601.tgz
-rw------- 1 root root 159917033 Feb 24 23:26 opennac-opennac.tpl-20180224_232601.tgz
-rw------- 1 root root 160047804 Feb 25 23:26 opennac-opennac.tpl-20180225_232601.tgz
-rw------- 1 root root 160150451 Feb 26 23:26 opennac-opennac.tpl-20180226_232601.tgz

The name is composed according to the following formula:

opennac-$fqdn_hostname-$year$month$day-$hour$minute$second.tgz

Each backups contains:

  • /etc/ directory

  • /usr/ directory

  • /var/ directory

  • MySQL database dump

5.2.8.1.1. Customize backup behavior

To customize the backup behavior, you can configure options in the /etc/cron.d/opennac-backup file. Below are the available options for the backup script:

[root@on-sta-qa ~]# /usr/share/opennac/utils/backup/opennac_backup.sh -h
Usage: /usr/share/opennac/utils/backup/opennac_backup.sh [options]

Backup openNAC files and database information.

Available options:
    -r|--retention RETENTION_LOGS        number of logs to retain
                                            Default: 7
    -s|--source-files SRC_FILES          source files and folders to backup
                                        (list elements separated by spaces
                                        and all list inside quotes)
                                            Default: "/etc /usr/share/opennac /var/lib/collectd"
    -d|--destination-folder DST_FOLDER   destination folder to store backup
                                            Default: /backup
    -f|--destination-file DST_FILENAME   destination filename to store backup
                                        (date and extension will be automatically added)
                                            Default: opennac-on-sta-qa
    -l|--log LOG                         backup log
                                            Default: /var/log/opennac/backup.log
    -t|--tmp-folder TMP_FOLDER           temporary folder, for internal script usage
                                            Default: /var/log/opennac/backup
    -a|--avoid-db-dump                   avoid database dump
    -h|--help                            display this help and exit

For example, if you want to configure the retention of backup logs to 2 days, you can modify the cron file as follows:

[root@on-sta-qa ~]# cat /etc/cron.d/opennac-backup
# opennac-backup
26 23 * * * root /usr/share/opennac/utils/backup/opennac_backup.sh -r 2 > /dev/null 2>&1

You can further customize the cron file by adding other options as needed.

Note

For operational purposes, the customer must copy it to a backup manager server.