Don't panic when deleting data by mistake: use tengxunyun hard disk snapshot (Snapshot) to realize one recovery

2026-05-29 阅读 10
1

In the daily server operation and maintenance and development, the most scalp-numbing operation is the classic one.

rm -rf /*

, or the wrong database executed an empty instruction without restrictions. Once the data was deleted by mistake, many people's first reaction was a buzz in their brains, and then they began to search for various extremely unreliable underlying data recovery software on the Internet. As a result, after a long time of trouble, the data was not found back, but the underlying disk was completely polluted.

In fact, if you are using tengxun cloud server (CVM or lightweight application server) and turn it on in advance

Disk Snapshots (Snapshot)

Deleting data by mistake is not the end of the world.

Today, I will not talk about virtual theories or profound codes. Starting from actual combat, I will teach you how to use Tengxun cloud snapshot to retrieve the mistakenly deleted data intact in 5 minutes.

The first stage: the bottom, understand the snapshot of the "regret medicine" logic

Before you do it, you must understand the underlying working principle of the snapshot, otherwise you are not sure how to use it, and may even cause secondary damage when rolling back.

Many people think that snapshots are like network disk backups, each time a complete copy of the entire hard disk data is stored.

Completely wrong.

If this is the case, if you buy a 100G hard disk, 10 snapshots will take up 1TB of space, which is simply too much for your wallet.

Tengxun Cloud's cloud hard disk snapshot uses

Incremental Snapshot"

Mechanism:

First Snapshot (Full): The system will make a complete copy of all written data blocks (Data Blocks) in your current hard disk and store them in Tengxun Cloud's extremely secure cold storage (usually object storage COS).

Subsequent snapshots (incremental): The system only compares the previous snapshot and copies only the modified or newly added data blocks during this period.

Core conclusion: This mechanism not only allows snapshots to be generated extremely quickly (usually in a few minutes), but also takes up very little storage space and is extremely economical. What's more, rollback snapshots are block-level replacements that are a hundred times faster than you can copy files.

The second stage: actual combat exercise-two life-saving schemes after the disaster

Suppose just now, due to the shaking hands of pig teammates or the wrong script, your server

/www/wwwroot

The core production code in the directory and the pictures uploaded by users are all cleared. At this time, please force yourself to calm down, don't knock orders in the server, log in directly

Tencent Cloud Console

.

Depending on your business situation, choose one of two rollback scenarios:

Scheme 1: Simple and crude "time and space shuttle" (directly rolling back the entire cloud hard disk)

This scheme is applicable to: your server has just been deployed for a short time, or the system disk of the whole server has completely collapsed and the trojan horse implanted by hackers has crashed. you need to let

The whole server completely returned to a good point in time in the past.

.

Core steps:

Must be shut down first: in the instance list, check your cloud server

Click "Shutdown" at the top ". When the hard disk is reading and writing, rollback is absolutely not allowed. Forced rollback will cause damage to the file system.

Find the corresponding snapshot: In the left-side navigation pane, find Disk> Snapshot List ". Keep your eyes open to see the "snapshot creation time" and find the nearest and healthiest snapshot point before you mistakenly deleted the data.

To perform a one-click rollback, click Rollback on the right side of the snapshot ". The system will pop up and warn you: "Rollback will overwrite all the data of the current cloud disk". After confirmation, click OK.

Restart: Wait for the progress bar to reach 100 (usually only 1~3 minutes), return to the instance list and click "power on". Log in to the server and you'll find that the system, the environment, and the code are all there, as if the disaster had never happened.

Phase 3: Advanced Progressive-Safer "surgical" data extraction (no impact on current business)

The above kind of whole-disk rollback is cool, but there is a fatal price:

It erases all newly generated data from the moment the snapshot was created to the current time.

Suppose your snapshot was generated at 2:00 a.m. yesterday and your teammates deleted a folder by mistake at 3:00 p.m. this afternoon. If you roll back the whole disk directly, it means that during the 13 hours of the day today, all new orders and newly registered accounts generated by other users will be erased together. This is unacceptable in a production environment.

How can we retrieve only the mistakenly deleted folders without moving the new data generated today? We use the "mount extraction method".

Top operation and maintenance standard operating process:

Create a "temporary data disk" with a snapshot: Log in to the Tengxun cloud console and enter the "snapshot list". Find the intact snapshot and click "New Cloud Disk" on the right ". Use this snapshot as a source and purchase a temporary volume-based cloud hard disk (delete it when it is used up, only a few cents).

Mount the temporary disk to the running server: After the hard disk is created, click "Mount" in the cloud disk list to select your server that is running business.

Enter the system to mount and extract files: use SSH to connect to the server and execute the lsblk command. you will find an extra disk partition (such as/dev/vdb). Create a new temporary mount point and mount it: Bashmkdir /mnt/backup mount /dev/vdb1 /mnt/backup. at this time, enter/mnt/backup/www/wwwroot, and the folder lying inside is the intact folder at 2:00 a.m. yesterday! Use the cp command to accurately copy the mistakenly deleted folder back to your real production directory (/www/wwwroot).

After finishing (saving money key): After the copy is completed, run umount /mnt/backup to unmount the disk. Return to the Tengxun cloud console, unhook and destroy (release) this temporary disk. The whole process does not affect any online running business, accurate stop loss.

The fourth stage: nip in the bud

However-how to configure the automatic line of defense with the least cost.

After watching the above high-energy operation, you may ask: "What if something happens one day and I find that I haven't taken a snapshot at all?"

It is not shown to manually point snapshots, and everyone is negligent. Enterprise-level operations must automate this.

Configure a periodic snapshot policy: enter "EVS Disk"-> "Periodic Snapshot Policy" in the Tencent Cloud console ". Click New to set a policy. For general corporate websites, it is recommended to set it to automatically create a snapshot at 3:00 a.m. every day and keep it for 7 days.

Cost Actuarial: Tengxun Cloud's snapshot is billed by volume (only a few cents will be deducted when the storage capacity is large enough). If you have a disk with a total of 50G and actually write 20G of data, the daily increment may be only a few hundred MB. At the end of a month, it may only cost you one or two dollars to maintain these seven backup points. Use a bunch of money cooked by kwantung to buy a perfect commercial insurance for the company's core assets.

Summary

In the era of cloud computing, "mistakenly deleting data" is no longer an irreversible disaster. Tengxunyun's cloud hard disk snapshot is the physical "time machine" you hold in your hand ". Remember two core principles:

At ordinary times, an automatic and regular snapshot strategy must be opened. After a disaster, unless the whole machine is paralyzed, the "new temporary disk mount" method is preferred for fine extraction.

Calm response, step by step, you are the most stable backbone of the team.

3
← 返回新闻中心