I have an AWS EC2 Windows Server 2012 R2 instance with a magnetic EBS-volume D:\ (Windows SO is on C:\).
My server works on D:\ writes everytime some temporally files in D:\temp (session file, cache etc.) and reads some static files in D:\htdocs.
I need do a daily consistent snapshot of EBS-volume without downtime
About this question a lot of people says:
Snapshot EBS if the volume is in use it is possible but not recommended
From official documentation:
You can take a snapshot of an attached volume that is in use. However, snapshots only capture data that has been written to your Amazon EBS volume at the time the snapshot command is issued. If you can pause any file writes to the volume long enough to take a snapshot, your snapshot should be complete.
and here:
EBS volumes and snapshots operate at a block level - a consequence of which allows snapshots to be taken while an instance is running, even if the EBS volume is in use. However, only data that is actually on the disk (i.e. not in a file cache) will be included in the snapshot. It is the latter reason that gives rise to the idea of consistent snapshots. The recommended way is to detach the volume, snapshot it, and reattach it
My question is: if the snapshot is inconsistent because when i do it there are writing operations, can i remount it? Since only files written is temporally files but they aren't important for me, if are damaged can i simple delete them (after i remount snapshot)? my only target it's to be safe the static file.
If you create a snapshot, you will be able to create a volume from it, and remount it without any issues.
HOWEVER: you are not guaranteed that the data in the volume is consistent.
Consider this scenario: you commit a 1 MB file to an SSD-backed EBS volume. This will require 4 x 256k IO operations. So the first 3 complete, then you take your snapshot, then the 4th block is written.
You will be able to create a volume from your snapshot, but your file will only be 768k in size - the final block will not be there, since it was written after the snapshot was created.
If you have control over what is writing to the disk, pausing it and flushing any caches is really the only way to ensure that the data on the resulting snapshot is consistent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With