In this section:

 

This section describes how to trigger automatic diagnostic snapshots.

Overview

This document will cover the steps and commands to execute a backup of the MySQL database on High Availability Edgeviews running version 16.3.0 or higher. This process will utilize a script introduced to EV 16.3.0 to create and store MySQL backup files to a NFS server that is mounted to each node in the cluster or locally to a location on the node itself.

Locally storing the database backup files on the node is not recommended. In the event of a system failure, those backup files can be lost.


Configure Database Backup


1. SSH to the first node of the cluster, and become root:

sudo su


2. Ensure the location to store the backup files exists:
           

  • For NFS: Verify that there is a mounted NFS server by listing the disk space with df -h on the node and ensuring there is a network connected mount, like the following:

            

  • For Local: Ensure that the disk has up to 2 to 3GB of disk storage using the df -h command, and that the directory exists. If not, create the directory with the mkdir command.

3. Navigate to the backup script’s location:

cd /opt/scc-build/scripts

4. Using a text editor, modify the mysql-database-backup-storidge.sh script with the following (example using the NFS path):

  • Line 11: Change the value between the quotes to the absolute path where the backup files are to be stored. Using the picture above for NFS, the line would
    look like:
BACKUP_PATH="/media/nfs"


       ● Line 12: Change the number of days the older backup files are stored for. If only seven days of backups are wanted, the line would look like:

RETENTION_DAYS=7

5. Save and close the mysql-database-backup-storidge.sh script.6. Is using the recommended CentOS 7 Linux distribution for the host operation system, the backup script can then be copied to one of the three locations to run. If
not using CentOS 7, automated script execution will have to be configured via that operating system’s anacrontab/crontab :
        ● Daily Backup: /etc/cron.daily

cp /opt/scc-build/scripts/mysql-database-backup-storidge.sh /etc/cron.daily

                                                   OR

● Weekly Backup: /etc/cron.weekly

cp /opt/scc-build/scripts/mysql-database-backup-storidge.sh /etc/cron.weekly

                                                    OR

● Monthly Backup: /etc/cron.monthly

cp /opt/scc-build/scripts/mysql-database-backup-storidge.sh /etc/cron.monthly


The MySQL database backup is now configured.

Restoring From MySQL Backup


1. SSH to the first node of the cluster, and become root:

sudo su


2. Identify the correct nodes currently running the MySQL services with the following commands, and make note of the values under the ID and NODE columns:
        ● docker service ps ev_mysql
        ● docker service ps ev_evapi-mysql
        ● docker service ps ev_ztp-mysql

3. Open a SSH connection as root (or using sudo or sudo su) to the nodes running the above services, then run the following command on each node using the proper service ID and backup file for the service.

Example:

docker exec -i uc2rlqaiyj3h /usr/bin/mysql -u root --password=edgeview < /media/nfs/2022-02-24-ev_mysql.sql


4. Once all three backup files have been applied, the database has been restored.