Skip to content
Source
Sign inSign up

Restore a backup

Site administration

Restore an analytics backup

The analytics server lost its data, and you need the events back. Restore the database from one of the nightly backups in R2.

1 min read

You need:

Important

On a new server, restore before you start cloudflared (step 6 of the setup). After that step, the queue puts new rows in the table.

1. Find the day that you want

The bucket gitflare-analytics has one folder for each day under backups/.

2. Make sure that the tables are empty

ClickHouse does not restore into a table that has rows. This command must print 0:

clickhouse-client --password "$(cat /root/.clickhouse-admin)" --query "SELECT (SELECT count() FROM analytics.events) + (SELECT count() FROM analytics.rank_actions)"

3. Restore the backup of that day

clickhouse-client --password "$(cat /root/.clickhouse-admin)" --query "RESTORE DATABASE analytics FROM S3('https://<account id>.r2.cloudflarestorage.com/gitflare-analytics/backups/<day>/')"

Done

Count the rows again, with the command of step 2. The count is now the number of events in the backup.