Environment
- YugabyteDB Anywhere - ALL
Issue
- What is minNumBackupsToRetain:
- minNumBackupsToRetain is a setting to avoid expiring and deleting all the backups for a schedule in case there is an issue where backups are failing for longer than the retention time of the most recent backup.
- For example, if a schedule is configured to run daily backups and retain them for 7 days, if backups fail for 8 days, the last good backup would be rolled off and there would be no valid point to which the system could be restored. This is where
minNumBackupsToRetain
comes in. This configures the number of minimum backups to retain.
-
The
minNumBackupsToRetain
field is not present in the UI and can currently only be set using the API when creating a new backup schedule.
Resolution
Steps:
Workaround 1:
- minNumBackupsToRetain can only be created via API currently when setting up a new backup schedule.
If you have not yet used the REST API, refer to the KB article How To Manage YugawareDB Anywhere Runtime Configuration Settings for instructions on how to retrieve the Customer UUID and generate a REST API authentication token.
$ curl --request POST \
--url "https://${YBA_HOST}/api/v1/customers/${CUUID}/create_backup_schedule" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "X-AUTH-YW-API-TOKEN: ${TOKEN}" \
-d '{
"universeUUID": "${universe_uuid}",
"cronExpression": "30 4 * * *",
"frequencyTimeUnit": "DAYS",
"timeBeforeDelete": 86400000,
"expiryTimeUnit": "DAYS",
"scheduleName": "api-schedule-1",
"backupType": "PGSQL_TABLE_TYPE",
"storageConfigUUID": "${storageConfigUUID}",
"minNumBackupsToRetain": 1
}'
where:
-
-
universeUUID - the UUID of the database Universe to back up
-
cronExpression - a cron expression specifying the backup schedule
-
frequencyTimeUnit - used when displaying the schedule in the UI; one of "HOURS", "DAYS", "WEEKS", etc.
-
timeBeforeDelete - how long to retain backups created by this schedule, in ms
-
expiryTimeUnit - as frequencyTimeUnit above but for the backup expiration time
-
scheduleName - a text string with the name to display in the UI for this schedule
-
backupType - used to specify whether this schedule backs up YCQL or YSQL data; one of PGSQL_TABLE_TYPE, YQL_TABLE_TYPE (other types are unneeded or deprecated)
-
storageConfigUUID - the UUID of the backup storage to which the backups should be written; can be retrieved using the List all customer configurations API endpoint
-
minNumBackupsToRetain - controls the number of backups that will be automatically reprieved from deletion for this schedule
-
Workaround 2:
-
Currently there is no way to edit minNumBackupsToRetain field in an existing schedule via API, but can be updated by updating the schedule config in the YBA postgres database.
-
Before starting, take a backup of the Platform database using yb_platform_backup.sh using the steps in this article Back up and restore YugabyteDB Anywhere
-
Connect to the platform Postgres Database:
$sudo docker exec -it postgres psql -U postgres yugaware
-
Start a transaction and make the update
yugaware=# select task_params::jsonb->'minNumBackupsToRetain' as minNumBackupsToRetain from schedule where schedule_uuid = 'f3cd7be4-a478-4d5c-b1bc-653c1d190ed5';
minnumbackupstoretain
-----------------------
3
(1 row)
yugaware=# begin;
BEGIN
yugaware=*# update schedule set task_params = jsonb_set(task_params::jsonb, '{minNumBackupsToRetain}', '1') where schedule_uuid = 'f3cd7be4-a478-4d5c-b1bc-653c1d190ed5';
UPDATE 1
yugaware=*# select task_params::jsonb->'minNumBackupsToRetain' as minNumBackupsToRetain from schedule where schedule_uuid = 'f3cd7be4-a478-4d5c-b1bc-653c1d190ed5';
minnumbackupstoretain
-----------------------
1
(1 row)
yugaware=*# commit;
COMMIT
Comments
0 comments
Please sign in to leave a comment.