Snapshots and backups
Create, restore and delete disk snapshots within your quota, and what backup support exists today.
A snapshot records the complete state of a disk at a point in time. Take one before risky changes such as software upgrades or system configuration edits, so you can roll back quickly if something goes wrong.
Snapshot quota
How many snapshots an instance can keep is set by its plan (with elastic plans you choose it with the 快照数 (Snapshots) slider when you buy). The 快照管理 (Snapshots) card on the instance detail page shows 快照配额: N 个 (Snapshot quota: N). Once you reach the quota you cannot create more until you delete an older snapshot.
Create a snapshot
- Go to 云服务器 > 我的实例 (Cloud Servers > My Instances) and click 管理 (Manage) on the instance to open its detail page.
- In the 快照管理 card, click 创建快照 (Create snapshot).
- In the 磁盘 (Disk) drop-down, choose the disk to snapshot (for example the system disk
SDA). - (Optional) In 备注 (Note), describe why you are taking it, for example "before PHP upgrade".
- Click OK.
The snapshot name is generated automatically from the creation time. Snapshots run in the background and appear in the snapshot list as soon as you submit. If the background job fails, the entry is removed automatically and does not count against your quota.
Before snapshotting write-heavy services such as databases, stop the service or run sync inside the OS to get a more consistent snapshot.
View snapshots
In the 快照管理 card, click 查看全部 (View all) to open the 快照列表 (Snapshot list). It shows each snapshot's 快照名称 (Name), 创建时间 (Created) and 备注 (Note).
Restore from a snapshot
- In the 快照列表, find the snapshot and click 恢复 (Restore).
- Confirm the prompt and the disk is rolled back to the state captured in the snapshot.
Restoring overwrites the disk's current data with the snapshot. Everything written after the snapshot was taken is lost and the operation cannot be undone. If the current data still matters, take another snapshot or copy the data off first.
After the restore finishes, log in through VNC or SSH and check that the system and your services are working.
Delete a snapshot
- In the 快照列表, click 删除 (Delete) on the snapshot.
- After you confirm, the snapshot is deleted in the background. When that finishes it disappears from the list and frees up quota.
Deleted snapshots cannot be recovered.
Things to keep in mind
- An instance runs one operation at a time. If you see 队列正在执行中无法继续操作 (A queued task is still running), wait for the previous task to finish and try again.
- Snapshots are stored together with the instance's disks. They are good for short-term rollback but are not a substitute for off-site backups. If the instance itself has a problem, its snapshots may be unavailable too.
- Reinstalling the OS rebuilds the system disk. Before reinstalling, make sure you no longer need snapshots of the old system.
Backups
The instance detail page has a 备份管理 (Backups) card with a 创建备份 (Create backup) button, which queues a backup job in the background. The console does not yet let you list, download or restore backups yourself. To use a backup that has been created, contact support.
Until then, back up important data to a location outside the instance yourself, for example:
# Sync a website directory to another server with rsync
rsync -az --delete /var/www/ backup@198.51.100.20:/backups/web01/
# Dump MySQL databases
mysqldump --all-databases --single-transaction | gzip > /root/db-$(date +%F).sql.gzSchedule these commands with cron, and test regularly that your backups actually restore.