Aliyun Snapshot (Snapshot) Practical Tutorial: How to Recover with One Click when Server Environment Collapses
In daily operation and maintenance, the most scalp-numb moment is when the system suddenly becomes unresponsive after typing a line of commands (such as updating the kernel, configuring permissions, or clearing the log) in a dark terminal and pressing Enter.
Then the website reported 502, SSH was completely unable to connect, and the entire production environment was completely paralyzed.
In the face of this "epic disaster", many novices will choose to reinstall the system and then reallocate the environment, guide data and fix bugs all night long, thus greatly hurting their vitality.
In fact, if you prepare ariyun's "snapshot (Snapshot)" in advance"
It's as simple as reading a file while playing a stand-alone game. Today, I don't want to talk about the concept of emptiness. I'll take you with me directly on pure dry goods.
thoroughly understand alibaba cloud snapshot configuration, one-click rollback operation, and the production environment avoidance guide in plain language.
Core logic: What is a snapshot?
Simply put, snapshots are the "time camera" of your server's hard drive ".
Before you want to carry out high-risk operations (such as upgrading the database, changing the system, changing the core code), click a "photo" to the cloud disk ". The photo records all the data in your hard disk for this second.
Once the system crashes in half an hour, you just need to take out this "photo" and you can
Let the whole hard disk instantly return to the state half an hour ago
. Even the code with the environment, even the temporary documents that were not finished at that time can be retrieved intact.
Step 1: How to manually create a snapshot before a high-risk operation (1 minute)
Don't be lazy, take a minute to make a backup before you prepare to toss the server environment, which can save you the pain of all-night troubleshooting.
Log in to the Alibaba Cloud console, search for and enter the ECS panel.
Click "Instance" in the menu on the left, find the server you are running, and click the instance name to enter the details page.
Find "cloud disk" in the left menu, and you will see the hard disk mounted on the server (usually at least one system disk).
Find the cloud disk you want to back up (such as the system disk d-xxxx), and click Create Snapshot on the right ".
Make a good name: the name must bring the operation notes at that time, such as 20260528-backup before upgrading PHP environment, so as to take a seat in the future.
Click OK. At this point the snapshot begins to be created asynchronously in the background. You can see it in the left side menu.
"Snapshot"
See progress in the list.
💡Big vernacular reminder: Creating a snapshot will not affect the normal operation of the server, and the website does not need to be shut down. It is usually created in a few minutes.
Step 2: How to roll back with one click (2 minutes) when the environment collapses
Now simulate the worst situation: you just failed to toss about the environment, and the system can't get up directly. At this time, we will use the snapshot just now to "read the file with one click".
⚠Iron Law: Life and Death Operations Before Rollback (Must See)
Before clicking back to roll back,
The cloud server (ECS) must be stopped first.
. A running server is not allowed to directly erase the underlying hard disk.
In the ECS instance list, check your server and click "Stop" at the bottom (if the system deadlock hits
Do not open, select "Force Stop").
Wait for the server status to change to "stopped" in red ".
Hands-on rollback:
In the navigation pane on the left, click Storage and Snapshots $\rightarrow $Snapshots ".
Find the snapshot you just created called 20260528-Backup before upgrading your PHP environment.
Click "Roll Back Cloud Disk" on the right ".
The system will pop up a prompt box full of warnings to the effect that "after rollback, all the new data you generated between the snapshot creation and this moment will disappear".
After confirming that there is no error, click "OK Rollback".
The rollback speed is extremely fast (usually within tens of seconds to 1 minute). After the status in the snapshot list returns to normal, return to the instance list and click
"Start"
button to open the server.
Log on to the server again, and you'll find that it's standing intact at the point in time before you were beaten.
Step 3: More advanced gameplay-configure automatic snapshot policy (anti-forget)
People always have a fluke mentality and often forget to take snapshots manually while playing. What if you encounter blackmail virus encryption one day or the server is tampered with by hackers in the middle of the night?
We need to turn on the "automatic snapshot policy" so that Aliyun can automatically take photos for us every night.
In the menu on the left, click Snapshot $\rightarrow $to switch to the Automatic Snapshot Policy tab.
Click "Create Policy": Creation Time: It is strongly recommended to select 02:00~04:00 in the morning (at this time, the website traffic is minimal and has almost zero impact on the business). Repeat frequency: check Monday to Sunday (daily backup). Retention time: The production environment is recommended to be retained for at least 7 days or 30 days. The expired old snapshot Aliyun will automatically delete it for you, so you don't have to worry about bursting the space.
After creating the strategy, click "Application Cloud Disk" and check your important system disk and data disk.
From then on, you have the equivalent of an automatic cycle of 7 days light machine.
Blood and Tears Avoidance Guide for Production Environment Snapshots
Snapshots are charged for storage! Don't keep it indefinitely! Alibaba Cloud snapshots are not free. Although it is cheaper than cloud disk, it is deducted according to the space actually occupied by your snapshot (by the amount of billing). How to avoid pits: After the temporary snapshot created manually is successfully built and the test website is confirmed to be no problem, you must manually delete it from the snapshot list! Otherwise it will lie there silently withholding your account balance.
Is the manual snapshot still available after the Pay-As-You-Go server is released? If you are using a Pay-As-You-Go ECS instance on Alibaba Cloud, when you no longer need the server and click Release, the system will erase the attached cloud disk and automatic snapshot by default. Life-saving practices: If you want to keep this environment for future use, before releasing the server, go to the snapshot console to check to make sure your snapshot is a "manual snapshot". As long as you don't actively delete the manual snapshot, it will remain in your account even if the server is gone. You can use this snapshot later
Create a new hard disk directly and mount it to the new server to get the data back.
Is the snapshot data safe when the database is writing wildly? A snapshot is a physical backup of an entire disk. If your server is running a highly concurrent MySQL database, at the moment of snapshot capture, there may be some data in memory that has not yet been written to the hard disk, which will lead to an "abnormal shutdown" error in the restored database. Standard practice: Do not rely solely on snapshots for extremely demanding production databases that cannot lose a single order. We must cooperate with the "Binlog backup provided by Aliyun RDS database" mentioned in the previous issue or export SQL files regularly with mysqldump inside the server. Multiple insurance is qualified for operation and maintenance.
To match the snapshot strategy is equivalent to pulling a safety net for yourself on the edge of the cliff. The next time I go to toss Linux all kinds of difficult and complicated diseases, I will naturally have confidence in my heart.
