快照和备份的区别

快照:创建快照时,存储每个数据块的元数据记录将复制到快照中。占用很少的空间,快照创建得非常快。

快照常见的两种技术:

(1)第一次写时复制(也简称写时复制,英文简称:COW):每当覆盖一个数据块时,该块就会先被复制到快照中(称之为:快照空间),然后再将要写入的数据覆盖到该数据块中(备注:只有快照创建之后的第一次覆盖会有此复制行为产生)。相当于流程为: 读-->写-->写

优点:空间的高效利用,因为快照只需要保留发生过变化的数据块,与数据卷相比要小得多。

缺点:引起数据卷性能的下降,这是因为创建快照之后,对数据卷的写操作会增加一个等待的过程 –即旧数据块复制到快照空间的过程。另外一个关键问题是每个快照必须依赖一个完整的数据卷。

(2)写时重定向(英文简称:ROW):要写入的数据直接写入到快照中。即数据卷存放的是创建快照时间点的旧数据,新数据最终存放在预留的快照空间。

优点:只需要1次写即可实现快照,不需要像写时复制一样需要1读+2写,写入效率上有了提升。

缺点:被删除的快照上的数据必须被复制到原始数据卷,并且做一致性回退。创建的快照越多,维护快照的复杂度也会以指数级别上升。此外原始数据集中会产生大量的碎片。

 

备份:完整复制,数据块全部拷贝的方式。

 

如下是QNAP(该产品采用写时复制机制)对于快照和备份之间的区别的凝练总结:

What a snapshot does?
In short Snapshot is versioning, or the ability to undo a change. If you take a snapshot every hour, for example, then all your files or folders can be reverted back to the sate they were at the time of any of your snapshots. So, if you get a virus, then you can just revert your files, folders, or whole volume to the state it was in before you got the virus

How is this different than a backup?
A backup is a complete copy of your data. So, if you have 5TB of data each copy will take up an additional 5TB of data. If you made a backup every 1 hour, then after just 10 hours, your backups would take 50TB of space. For this reason, it is not common to save many versions of your backups and backups are not good for versioning.Snapshots are great for versioning because they are not backups and they can have many versions without taking up much space. A Snapshot only needs to save enough information to undo a change and that makes it take less space than a backup.

When are Snapshots Small?
When you only add files to the NAS, you don’t need to save blocks of data to the snapshot. The Snapshot just needs to have the metadata recording what blocks have been added to the NAS since the creation of the snapshot.

What makes Snapshots Big?
When you delete files, the snapshot needs to be able to restore the files you deleted. To do that, any block of data you delete and overwrite will be saved to the snapshot. Saving blocks of data to the snapshot takes much more space than just saving metadata. So, deleting files makes your snapshot size grow much more than adding file

Conclusion:
Most people delete some files and make some changes to their files, but not enough to make the snapshots get too big.  You could never get close to this many complete backups without taking up huge amounts of space. That is why Snapshots are much better than backups for versioning. But snapshots don’t protect you from drive failure so it is still good to have RAID redundancy and at least one backup of your data to another device.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MongoDB的快照备份是一种常用的数据备份方法,它可以在特定时间点对数据库进行全量备份。下面是MongoDB快照备份的介绍: 1. 快照备份原理:MongoDB的快照备份是通过文件系统级别的快照技术来实现的。它会在指定时间点对数据库的数据文件进行拍摄,生成一个数据文件的副本,这个副本可以用于恢复数据库到该时间点的状态。 2. 快照备份的优点: - 高效性:快照备份只需要拍摄数据文件的副本,不需要遍历整个数据库,因此备份速度较快。 - 数据一致性:快照备份是在文件系统级别进行的,可以保证备份数据的一致性,不会出现部分数据备份成功而部分数据备份失败的情况。 - 空间占用小:由于快照备份只是生成数据文件的副本,不需要额外的存储空间,因此占用的空间相对较小。 3. 快照备份的使用: - 文件系统快照:可以使用操作系统或者存储设备提供的文件系统快照功能来进行备份。 - MongoDB工具:MongoDB也提供了一些工具来进行快照备份,如mongodump和mongorestore命令行工具。 4. 注意事项: - 快照备份只能用于全量备份,无法实现增量备份。 - 在进行快照备份时,需要确保数据库处于稳定状态,避免备份过程中的写操作对数据的一致性造成影响。 - 快照备份只能用于恢复到备份时的状态,无法实现精确到某个操作的恢复。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值