Backup
Restore is possible only to the same version of Collector from which the backup was made.
Flows Backup
Backup should be run on the server that stores the flows.
If Collector is stopped before starting the backup, you need to start
the metrics storage module (docker-compose up -d clickhouse
)
and stop it after the backup procedure (docker-compose stop clickhouse
).
CID=$(docker-compose ps -q clickhouse) \
&& VERSION=$(docker inspect -f '{{index .Config.Labels "build.branch"}}' $CID) \
&& ARCHIVE=$(docker-compose exec clickhouse sh -c "backup $VERSION") \
&& docker cp $CID:$ARCHIVE . \
&& docker-compose exec clickhouse rm $ARCHIVE
Collector Settings Backup
If Collector is stopped before starting the backup, you need to start
the backend module (docker-compose up -d backend
).
CID=$(docker-compose ps -q backend) \
&& VERSION=$(docker inspect -f '{{index .Config.Labels "build.branch"}}' $CID) \
&& ARCHIVE="settings-$(date +"%Y-%m-%d_%H-%M")-${VERSION}.zst" \
&& nsenter -n -t "$(docker inspect -f '{{ .State.Pid }}' $CID)" curl -Sfs localhost:8000/settings -o bolt_db \
&& zstd -zq -o $ARCHIVE --rm bolt_db
Restoring From a Backup
The commands assume that the backup files
are located in the working directory /srv/collector
,
however, the location of the files can be anything:
- on a remote server;
- on USB storage devices;
- in any system directory.
In this case, the commands must contain the full path to the backup files.
Restoring Flows
Runs on the server that stores the metrics. Restore is performed without removing the old data. To avoid data duplication, before restoring, you should delete old records for the same period according to the instruction DB reduction
Run Clickhouse (If it is stopped)
docker-compose up -d clickhouse
Select a backup, transfer it to the container and restore the data
ARCHIVE=flows-X.tar.zst \ && CID=$(docker-compose ps -q clickhouse) \ && docker cp ./$ARCHIVE $CID:/tmp/ \ && docker-compose exec clickhouse sh -c "restore /tmp/$ARCHIVE"
Delete a backup archive from a container
docker-compose exec clickhouse rm /tmp/$ARCHIVE
Restoring collector settings
Backend module needs to be stopped to restore the settings.
Stop the backend (if it is running)
docker-compose stop backend
Select a backup, extract the settings file and transfer it to db volume
ARCHIVE=settings-X.zst \ && VOLUME=$(docker volume create collector_db) \ && BOLT_DIR=$(docker volume inspect ${VOLUME} -f '{{.Mountpoint}}') \ && zstd -dqf -o $BOLT_DIR/bolt_db $ARCHIVE
Run Collector with restored settings
docker-compose up -d