Backup

Restore is possible only to the same version of Collector from which the backup was made.

Script for Backup, Restore, and Data Cleanup

The script provides the following commands:

  1. backup-flow – Make a backup of traffic data
  2. backup-settings – Make a backup of collector settings
  3. restore-flow – Restore traffic data from a backup
  4. restore-settings – Restore settings from a backup
  5. clean-flow – Remove records before a specified date

In addition to the instructions below, run:

./collector_backup.sh usage

for detailed help on how to use the script.

Downloading the Script

wget https://docs.mitigator.ru/collector/master/maintenance/collector_backup.sh

Backup of Traffic Data

Run the backup on the server where flows are stored. If the Collector is stopped before starting a backup, start the clickhouse container (docker-compose up -d clickhouse).

To create the backup:

./collector_backup.sh backup-flow

Backup of Collector Settings

If the Collector is stopped prior to backing up, start the backend module (docker-compose up -d backend):

./collector_backup.sh backup-settings

Restoring from a Backup

The following examples assume that the backup files reside in the current directory /srv/collector, but you can store backups anywhere:

  • On a remote server;
  • On a USB drive;
  • In any system directory. If the archives are in a different directory, specify the full path in each command below.

Restoring Traffic Data

Run the restore on the server where flows are stored. Data is restored without purging old records. To avoid duplicate data for the same period, remove old records by running clean-flow beforehand. For example:

./collector_backup.sh clean-flow 1970-01-01

where 2024-12-31 is the cutoff date up to which data will be removed. You can determine this date by checking the archive name, which specifies the traffic data range it contains. Note that the date format is YYYY-MM-DD, where YYYY is the year, MM is the month, and DD is the day.

Steps to Restore Traffic Data

  1. If ClickHouse is stopped, start it:
    docker-compose up -d clickhouse
  2. Run the restore-flow command with the archive:
    ./collector_backup.sh restore-flow flows-2024-01-01.tar.zst

where flows-2024-01-01.tar.zst is the path to the archive with the data to restore.

Restoring Collector Settings

Restoring settings must be done with the backend module stopped.

  1. Stop the backend (if it is running):
    docker-compose stop backend
  2. Run the restore-settings command with the archive:
    ./collector_backup.sh restore-settings settings-2024-01-01.zst
    where settings-2024-01-01.zst is the path to the archive with the settings to restore.
  3. Start the Collector with restored settings:
    docker-compose up -d