Understand Aiven for MySQL® backups
Aiven for MySQL databases are automatically backed-up, with full backups daily, and binary logs recorded continuously. The number of stored backups and the retention time depend on your service plan. For the exact figures, see Backup retention. Full backups are version-specific binary backups, which when combined with binlog allow for consistent recovery to a specific point in time (PITR).
One thing to consider is that you may modify the backup time configuration option in Advanced configuration in Aiven Console which will begin shifting the backup schedule to the new time. If there was a recent backup taken, it may take another backup cycle before it starts applying new backup time.
To be able to safely make backups, MySQL INSTANT ALTER TABLE always use the INPLACE or COPY algorithm instead of INSTANT. Specifying ALGORITHM=INSTANT does not fail but automatically falls back to INPLACE or COPY as needed.
Backup retention
Full backups
Aiven takes a backup of your service every 24 hours. It is a full backup unless you enable incremental backups. Your service plan defines how many backups Aiven stores, and therefore how far back you can restore. As new backups are taken, the oldest ones are removed. For the backup history of each plan, see High availability of Aiven for MySQL®.
Binary logs
Aiven uploads binary logs to backup storage continuously and keeps them as long as the backup they belong to. Your plan decides how far back you can restore.
Binary log retention on the service disk
The binlog_retention_period advanced parameter sets how long binary log files stay on
your service's disk after they are backed up. It exists for tools that read binary logs
from the server, such as Debezium. It does not change how far back you can restore.
When the parameter is not set, binary logs stay on the disk for 600 seconds. The shortest retention you can set is 600 seconds. By default, the longest retention you can set is 86400 seconds (24 hours). To keep binary logs for up to 1814400 seconds (21 days), contact Aiven support. If your service has enough disk space for the additional binary logs, Aiven raises the limit for the whole project.
Longer binary log retention uses more disk space on your service. Review your disk usage before you increase the retention period. See Prevent a full disk.
Reducing binlog_retention_period can make a large batch of binary logs eligible for
purge at once. Depending on the volume, this can stall the MySQL commit path and block
writes until the purge completes. Lower the value gradually, in small decrements, during
a low-traffic window.
To set binlog_retention_period, see
binlog_retention_period
in the advanced parameters reference.
MySQL backups and encryption
All Aiven for MySQL backups use the myhoard software to perform encryption. Myhoard utilizes Percona XtraBackup internally for taking a full (or incremental) snapshot of MySQL.
Since Percona XtraBackup
8.0.23 the --lock-ddl
option is enabled by default. This ensures that DDL changes cannot be
performed while a full backup process is ongoing. This is important to
guarantee that the backup service is consistent and can be reliably used
for restoration.
With this feature enabled, if you try to run CREATE, ALTER, DROP,
TRUNCATE or another command during backup, you may receive the message
Waiting for backup lock. In this case, wait till the backup is
complete for running such operations.
Configure the backup schedule
Set the time of day when the daily backup is taken.
To edit the backup schedule for your service:
- Console
- Aiven API
- Aiven CLI
- Terraform
- In your service, click Backups.
- Click Actions > Configure backup settings.
- Click Add configuration options.
- Add
backup_hourandbackup_minute, and set their values. - Click Save configuration.
Call the ServiceUpdate
endpoint, and add the following properties to the user_config object:
curl --request PUT \
--url https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{
"user_config": {
"backup_hour": BACKUP_HOUR,
"backup_minute": BACKUP_MINUTE
}
}'
Replace the following:
SERVICE_NAME: the name of your service.PROJECT_NAME: the name of your project.BACKUP_HOUR: the hour when the service backup starts. Accepted values are integers between0and23.BACKUP_MINUTE: the minute when the service backup starts. Accepted values are integers between0and59.
Run the avn service update command,
and add the following properties to the user_config object:
avn service update SERVICE_NAME \
--project PROJECT_NAME \
--user-config '{
"backup_hour": BACKUP_HOUR,
"backup_minute": BACKUP_MINUTE
}'
Replace the following:
SERVICE_NAME: the name of your service.PROJECT_NAME: the name of your project.BACKUP_HOUR: the hour when the service backup starts. Accepted values are integers between0and23.BACKUP_MINUTE: the minute when the service backup starts. Accepted values are integers between0and59.
Use the backup_hour and backup_minute attributes in
your service resource
to set the start time for backups.
If a backup was recently made, it can take another backup cycle before the new backup time takes effect.
Related pages