Kubernetes CronJob to backup, compress (with gzip --rsyncable
), and finally
use restic
to backup your DBs to an S3 endpoint.
Advantages:
- using mariadb:latest Docker image, to ensure I don't use an outdated
mariadb-dump
binary - backing up each database in a separate file, to make for easier restore
- compressing the backups with gzip and the
--rsyncable
option (details here), which makes gzip "regularly reset his compression algorithm to what it was at the beginning of the file", so that changes to a portion of the file do not alter the whole compressed output, which permits to make incremental backups. - using restic to store the backups on an S3 endpoint (Cloudflare R2, with a generous free tier!), which makes for simple management and rotation, as well as for simple restores.
The CronJob can be used as is, and the secrets obviously need some adaptations !