This role adds a cron to backup MySQL & friends using mysqldump.
Optionally encrypts backups using provided GPG keys.
Optionally copies backups to object storage (S3 or GCS).
mysqldumpmust be present on the system.- influxevent must be installed if metrology is used
backup_mysql_exclude(default: ""):grepexclude pattern for databasesbackup_mysql_keep(default: 30): how many backups do we keep locallybackup_mysql_s3bucket(default: ""): S3 bucket to export backups tobackup_mysql_gcloudbucket(default: ""): GCS bucket to export backups tobackup_mysql_destination(default: "/var/backups/mysql/"): path to store local backups inbackup_mysql_cron_time(default: "15 */2 * * 0-7"): cron entry for backupsbackup_mysql_gpg_keys(default: []): list of gpg keys URLS to encrypt backups forbackup_mysql_user: backup userbackup_mysql_password: backup password
If backup_mysql_gpg_keys is populated with GPG keys URLs, backups will
be encrypted for those keys. When no keys are provided, backup will not be
encrypted.
If encryption is used, only encrypted backups will be pushed to object storage.
If encryption is not used, unencrypted backups will be pushed to object storage.
Each object in the backup_mysql_gpg_keys list must have an id and a url
attribute:
mariadb_backup_gpg_keys:
- url: https://gitlab.com/alice.gpg
id: AAAA40FC29B8AAAA
- url: https://gitlab.com/bob.gpg
id: BBBBE221A5D7BBBB
Buckets must be set in backup_mysql_s3bucket or backup_mysql_gcloudbucket
if you want to offload backups to object storage.
This role expects objects storage to be already setup if you intend to use it.
s3cmd and gsutil are used respectively for AWS S3 and GCS.
See ansible-gcloud for GCS.
For GCS, we recomment configuring the bucket with:
- a lifecycle policy to expunge old backups (see Lifecycle in bucket settings)
- a retention policy to ensure backup immutability (see Protction in bucket settings)
If backup_mysql_influxevent and telegraf_output_influxdb are set, the role
will use influxevent to
send backup events to an influxdb server.
InfluxEvent must be installed if you intend to use it (see https://github.com/devops-works/ansible-influxevent).
The following variables are required:
telegraf_output_influxdb.databasetelegraf_output_influxdb.urlstelegraf_output_influxdb.usernametelegraf_output_influxdb.password
See https://github.com/devops-works/ansible-telegraf#variables for more information on those vars.
None
Try this role many times and ensure it fits your needs before using it for production...
MIT
Patches welcome!