This error occurs when you attempt to perform a backup control plane operation (create, delete, or restore) on a DynamoDB backup that is already involved in another operation. Wait for the current operation to complete before retrying.
The BackupInUseException error indicates that there is an ongoing conflicting backup operation on your DynamoDB backup or table. When you try to create a new backup, delete an existing backup, or restore from a backup while another operation is already in progress on the same backup, DynamoDB rejects the request to prevent data inconsistency. This typically happens because backup operations are serialized at the backup level—only one control plane operation can act on a specific backup at a time.
Use the describe-backup command to see if your backup is in a stable state:
aws dynamodb describe-backup --backup-arn arn:aws:dynamodb:region:account-id:table/table-name/backup/backup-idLook for the BackupStatus field. It should be either AVAILABLE or DELETED. If it shows CREATING or DELETING, the operation is still in progress.
If the backup status is CREATING or DELETING, wait for the operation to finish. This typically takes a few minutes. You can continue checking the status with the describe-backup command or monitor via the AWS Management Console under Backups.
Once the backup status shows AVAILABLE, retry your original operation (create, restore, or delete). If you're programmatically retrying, implement exponential backoff:
const { DynamoDBClient, RestoreTableFromBackupCommand } = require('@aws-sdk/client-dynamodb');
const client = new DynamoDBClient({ region: 'us-east-1' });
async function restoreWithRetry(backupArn, tableName, maxRetries = 5) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const command = new RestoreTableFromBackupCommand({
BackupArn: backupArn,
TargetTableName: tableName
});
const response = await client.send(command);
console.log('Restore started:', response.TableDescription.TableArn);
return response;
} catch (error) {
if (error.name === 'BackupInUseException' && attempt < maxRetries) {
const delay = Math.pow(2, attempt - 1) * 1000; // Exponential backoff
console.log(`Attempt ${attempt} failed. Retrying in ${delay}ms...`);
await new Promise(resolve => setTimeout(resolve, delay));
} else {
throw error;
}
}
}
}
restoreWithRetry('arn:aws:dynamodb:region:account:table/MyTable/backup/id', 'MyTable-Restored');If you're performing batch operations, add a status check before each operation:
import boto3
import time
dynamodb = boto3.client('dynamodb')
def wait_for_backup_available(backup_arn, timeout=300):
start_time = time.time()
while time.time() - start_time < timeout:
response = dynamodb.describe_backup(BackupArn=backup_arn)
status = response['BackupDescription']['BackupDetails']['BackupStatus']
if status == 'AVAILABLE':
return True
elif status in ['DELETED', 'CREATING', 'DELETING']:
print(f'Backup status: {status}, waiting...')
time.sleep(5)
else:
raise Exception(f'Unexpected backup status: {status}')
raise TimeoutError(f'Backup did not become available within {timeout} seconds')
wait_for_backup_available('arn:aws:dynamodb:region:account:table/MyTable/backup/id')DynamoDB backup operations are subject to rate limits: CreateBackup and DeleteBackup can be called up to 50 times per second, while RestoreTableFromBackup is limited to 10 times per second per account. Additionally, DynamoDB allows up to 500 concurrent table operations (CreateTable, UpdateTable, DeleteTable, UpdateTimeToLive, RestoreTableFromBackup, and RestoreTableToPointInTime) per account. If you hit the BackupInUseException frequently during high-volume operations, consider implementing request queuing or spacing out backup operations. Note that backup operations do not consume provisioned throughput, and Point-in-Time Recovery (PITR) may be a better solution for frequent restoration scenarios as it offers per-second granularity without explicit backup management.
ImportConflictException: There was a conflict when attempting to import to the table
How to fix 'ImportConflictException: There was a conflict when attempting to import to the table' in DynamoDB
ResourceNotFoundException: Requested resource not found
How to fix "ResourceNotFoundException: Requested resource not found" in DynamoDB
TrimmedDataAccessException: The requested data has been trimmed
How to fix "TrimmedDataAccessException: The requested data has been trimmed" in DynamoDB Streams
GlobalTableNotFoundException: Global Table not found
How to fix "GlobalTableNotFoundException: Global Table not found" in DynamoDB
InvalidExportTimeException: The specified ExportTime is outside of the point in time recovery window
How to fix "InvalidExportTimeException: The specified ExportTime is outside of the point in time recovery window" in DynamoDB