Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

AWS Ops Automation and automated backup

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Background

EC2 backup of AWS can be done in many ways. If the administrator is familiar with scripts and Lambda, it can be backed up regularly through Cloudwatch events, or even a simple PowerShell script can be run directly in Windows's scheduled tasks.

AWS officially provides a package of solutions called ops automation, which is very suitable for administrators who do not understand scripts at all. After configuration, administrators can flexibly customize operations through the corresponding tag.

The screenshot below is an official sketch.

The specific explanation and configuration wizard process can refer to this link, but Chinese translation is not available for the time being.

Https://aws.amazon.com/solutions/ops-automator/

For the average user, looking at this diagram can understand his process from a high-level abstract point of view, but there is no need to know exactly how to call it. It is more important to know how to configure and use it.

Simply explain the process of installation and configuration. Through Cloudformation, we can install a stack template called AWS Ops Automator (I call it the main template). This stack will automatically configure a series of micro services, including Lambda functions, DynamoDB database, etc., and it will automatically create a S3 bucket and save six stack template files in this bucket, which corresponds to his six task functions: create and copy snapshots. Delete snapshots, replace instances, change instance types, and mark instances by cpu utilization. If we need one of his functions, we need to add a new stack (I call it a task template) again through the corresponding template file. For example, if we need to implement a function of creating snapshots regularly, we need to first configure a master stack, then configure a task stack that creates snapshots regularly, and then call the task template through this master template

So how do you invoke these functions? We mark the tag on the corresponding EC2 or snapshot, assign the tag name of AWS Ops Automator to key, and then assign the tag name of the corresponding task stack to value, and he will call the corresponding task stack through the main stack.

If this logic is confusing just by looking at the text, the easiest way to understand it is to do it once. Take chestnut as an example, I intend to make snapshot backups at regular times every day at the 4 points of 8bureaux 30, 11, 15 and 20:30, and then all snapshots will be deleted automatically for more than 30 days. Let's see how to achieve it.

Installation configuration process install main template

First of all, install our main template, pay attention to select the region you need in the upper right corner, his installation wizard is installed in US East by default, be sure to remember to modify it.

The key to configuring the content of stack is taskscheduler tagname, which is the name of key when we add tag later.

Click next

Review for a moment

Remember to check the bottom IAM option

Then he will automatically start configuring related resources and micro-services.

After the status changes to Complete, click output to view the corresponding S3 bucket name

Click the corresponding bucket to see that there are two directories. AccountsConfiguration is used to configure IAM permissions for other accounts, which can be ignored temporarily if we use this main account. TaskConfiguration includes 6 Task Template, that is, the task template we need to operate.

Install task template

Click in and have a look.

Click on Ec2CreateSnapshot.template and record his URL address

Then go back to Cloudformation and create a new stack through this template

Set it up according to your own needs. The key here is that Task interval needs to be configured in cron format.

Other custom attributes, such as time zone

And automatically add the corresponding tag to the created Snapshot. Note that this Delete30 is the name of the stack I'm going to create next, and its function is to delete snapshots automatically.

Wait a moment, the backup stack will be ready.

Create configuration Delete30 stack

This step is basically similar to the above, except that we need to use Ec2DeleteSnapshot.template

The relevant configuration is as follows

Time zone

Note that the deletion is not based on time, but is triggered every time a new snapshot is created. According to my observation, about 15 minutes after the creation of the snapshot, he will scan the volume-related snapshot and, if marked, delete the old snapshot according to the set threshold.

Set the threshold for deletion, either according to the number of days or the total number

Create a good look

Tag marker

Finally, take a look at how to tag. Click on an EC2 to mark it.

According to the time I set, he will back up automatically. On the generated snapshot, we can see the corresponding information.

If we set up multiple stack for different task template, we can distinguish them with commas when marking them.

View history

Beans usually check the relevant records in cloudtrail, but you can see that the log is relatively messy.

Fortunately, AWS provides Athena, which can convert the log of cloudtrail into table, and then query it through sql statement.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report