How to use the command 'aws backup' (with examples)
The AWS Backup command line interface (CLI) provides a unified and centralized way to automate and streamline the data protection requirements of businesses. It enables users to manage and orchestrate backups for Amazon Web Services (AWS) services, safeguarding their critical data. The command allows users to perform various backup-related tasks such as creating, viewing, and deleting backup plans, as well as listing report jobs, thereby ensuring robust and reliable data protection within AWS environments. In this article, we’ll explore each of these functionalities with detailed examples.
Use case 1: Return BackupPlan details for a specific BackupPlanId
Code:
aws backup get-backup-plan --backup-plan-id id
Motivation:
Understanding the specifics of a backup plan is crucial for maintaining the integrity and efficiency of data protection strategies. This command is used to retrieve the comprehensive details of a particular backup plan identified by the BackupPlanId. It aids administrators in quickly accessing information related to schedule, lifecycle, and rules associated with the backup plan.
Explanation:
aws backup get-backup-plan
: This is the primary command syntax to access AWS Backup functionalities related to getting backup plans.--backup-plan-id
: This argument specifies the unique identifier of the backup plan whose details are being requested. Theid
is a placeholder that stands for the actual BackupPlanId value assigned to a specific backup plan in AWS.
Example output:
{
"BackupPlanId": "1234-abcd-5678-efgh",
"BackupPlanName": "DailyBackup",
"VersionId": "1a2b3c4d",
"Rules": [
{
"RuleName": "DailyRule",
"TargetBackupVaultName": "Default",
"ScheduleExpression": "cron(0 12 * * ? *)",
"StartWindowMinutes": 60,
"CompletionWindowMinutes": 180
}
]
}
Use case 2: Create a backup plan using a specific backup plan name and backup rules
Code:
aws backup create-backup-plan --backup-plan plan
Motivation:
Automating the creation of backup plans allows organizations to efficiently manage their backup operations by customizing backup rules and schedules. This command is used to create a new backup plan, incorporating specified rules that dictate how and when backups should occur, thereby ensuring data protection policies are consistently applied.
Explanation:
aws backup create-backup-plan
: This command initializes the creation process for a new backup plan.--backup-plan
: This argument is followed by a JSON-formatted string or a file that contains the details of the backup plan configuration, including the plan name and a set of backup rules.
Example output:
{
"BackupPlanId": "abcd-1234-efgh-5678",
"VersionId": "1x2y3z",
"CreationDate": "2023-09-21T12:00:00Z",
"BackupPlanArn": "arn:aws:backup:region:account-id:backup-plan:abcd-1234-efgh-5678"
}
Use case 3: Delete a specific backup plan
Code:
aws backup delete-backup-plan --backup-plan-id id
Motivation:
Over time, backup requirements change, and certain backup plans may no longer be necessary. Deleting outdated or unnecessary backup plans helps streamline backup management and free up resources. This command facilitates the removal of a backup plan described by the BackupPlanId, ensuring that only relevant and active plans are maintained.
Explanation:
aws backup delete-backup-plan
: This command is responsible for the deletion process of a backup plan.--backup-plan-id
: The unique identifier of the backup plan to be deleted. Theid
stands for the actual BackupPlanId designated to a specific backup plan in AWS.
Example output:
{
"Code": "DeleteInProgress",
"Message": "The backup plan is being deleted."
}
Use case 4: List all active backup plans for the current account
Code:
aws backup list-backup-plans
Motivation:
Identifying and reviewing all current backup plans within an account enables organizations to have a cohesive understanding of their data backup landscape. This command lists all active backup plans, providing an overview that can be critical for auditing and compliance purposes.
Explanation:
aws backup list-backup-plans
: This command invocation lists all the active backup plans associated with the current AWS account. It doesn’t require additional arguments because it retrieves all relevant plans automatically.
Example output:
{
"BackupPlansList": [
{
"BackupPlanId": "abcd-1234",
"BackupPlanName": "DailyBackupPlan",
"CreationDate": "2023-09-21T12:00:00Z"
},
{
"BackupPlanId": "efgh-5678",
"BackupPlanName": "WeeklyBackupPlan",
"CreationDate": "2023-09-22T13:00:00Z"
}
]
}
Use case 5: Display details about your report jobs
Code:
aws backup list-report-jobs
Motivation:
Monitoring and evaluating report jobs are vital for ensuring accountability and effectiveness in backup operations. This command provides insights into the report jobs, detailing the status and outcomes, which helps administrators analyze backup activities and identify issues proactively.
Explanation:
aws backup list-report-jobs
: This command is used to fetch and display all the report jobs associated with the backup activities that have been executed in your AWS account. Report jobs typically provide detailed insights and metrics related to backup operations.
Example output:
{
"ReportJobs": [
{
"ReportJobId": "report-1234",
"CreationTime": "2023-09-25T15:00:00Z",
"Status": "COMPLETED",
"ReportPlanArn": "arn:aws:backup:region:account-id:report-plan:report-1234"
},
{
"ReportJobId": "report-5678",
"CreationTime": "2023-09-28T13:30:00Z",
"Status": "IN_PROGRESS",
"ReportPlanArn": "arn:aws:backup:region:account-id:report-plan:report-5678"
}
]
}
Conclusion:
The AWS Backup CLI offers powerful capabilities for managing and orchestrating backup strategies within AWS environments. From retrieving backup plan details to creating new plans, deleting obsolete ones, and monitoring report jobs, these commands facilitate comprehensive data protection management. By understanding each command’s purpose and application, administrators can efficiently protect critical data and optimize their backup operations.