Skip to main content

Backup and Restore

Backup strategy for the IonGuard platform to ensure data recovery in case of failure.

What is included in the backup

ComponentContentMethod
MariaDBApplication database (tenants, sites, users, alerts, audit)mariadb-dump
InfluxDBBLE signal time-series datainflux backup
.env fileInstallation configuration and secretsDirect copy
client/ directoryClient-specific dataDirect copy

The backup does not include Docker images, application code, or logs — these are recoverable via reinstallation.

Manual backup

Run the backup script on the server:

cd /home/iongrade/ionguard
./scripts/makeBackup.sh

Result

The backup is saved at:

/home/iongrade/ionguard/backup/{timestamp}_iongrade_{host}_ionguard.tar.gz

SaaS deploy

In SaaS mode, the backup is automatically sent to S3 after generation:

s3://iongrade-backups/ionguard/{deploy}/

The upload has 3 retry attempts in case of network failure.

Automatic backup

Configure a cron job for periodic backups:

# Daily backup at 02:00
0 2 * * * cd /home/iongrade/ionguard && ./scripts/makeBackup.sh >> logs/backup.log 2>&1

Restore

1. Restore MariaDB database

cd /home/iongrade/ionguard

# Extract the backup
tar -xzf backup/{file}.tar.gz -C /tmp/restore/

# Import the SQL dump
./scripts/comp.sh exec -T ionguard_mariadb \
mariadb -u ionguard -p"$(grep DB_PASSWORD .env | cut -d= -f2)" \
ionguard < /tmp/restore/mysql/tmp/ionguard.sql

2. Restore InfluxDB

# If the backup contains InfluxDB data
./scripts/comp.sh exec -T ionguard_influxdb \
influx restore /tmp/restore/backup/influx_tmp/ \
--org iongrade --bucket ionguard

3. Restore configuration

# Restore .env (if needed)
cp /tmp/restore/.env /home/iongrade/ionguard/.env

# Restart services
./scripts/restartAllServices.sh

Best practices

  • Back up before any version update
  • Keep at least 7 days of local backups
  • Test the restore periodically in a staging environment
  • Store backups in a separate location from the production server
  • The upgrade script (upgradeToNewestVersion.sh) automatically backs up before applying the update