Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In my early days as KVM admin, when I had to do a backup of a VM image, I followed the next steps:

  1. Pause the VM
  2. Snapshot LVM volume
  3. Resume the VM
  4. Copy image
  5. Remove LVM snapshot

Now I've got some machines in EC2, but I'm facing a doubt:

Amazon official documentation says

"you should stop the instance before taking the snapshot"

but there's sometimes you can't stop a production instance. I've been taking snapshots without stopping the instance and I've restored it (everything's gone fine) but the doubt is knocking my head time to time.

So my question is, can I pause (stop is not and option) an EC2 instance so that I can take a consistent snapshot of it?

share|improve this question

4 Answers 4

Pausing is not possible. Stopping the instance will insure that your filesystems are consistent. Using fsfreeze is another method for insuring you have quiesced your filesystems.

The script ec2-consistent-snapshot is currently the de-facto standard, open source solution for doing this on Linux based instances. You can also handle MySQL filesystem backups. Running it requires AWS API permissions and it has to be run on the instance in question to insure the filesystems are consistent. I have used it with success for some time.

share|improve this answer

No, it cannot be paused.

I also make snapshots on live servers and have yet to run into an issue, and I agree that it would be nice to be able to suspend writes during that time.

The other option is to use 'Create AMI from this instance' which seems to do something similar to a pause, in that it temporarily stops the instance but without releasing IP's or losing instance storage. It's not quite the same as creating a snapshot though, so may not be useful for daily backups.

share|improve this answer
    
"and have yet to run into an issue" is not really good enough to risk data! –  mtm Jul 16 at 9:20
    
@mtm I was not saying that the OP shouldn't worry about it. It depends on the data and the person. Only he can determine whether something is in his comfort zone. I have personally learned to live with it, in part because no better solution is easily available. The snapshot appears to be 'good enough'. –  Martijn Heemels Jul 16 at 13:12

No, you can't pause an EC2 instance, only stop.

Pausing a VM does not guarantee a consistent snapshot. In fact, pausing a VM to take an underlying snapshot is worse than taking a local LVM snapshot from a running system. Running an LVM snapshot will at least flush it's write buffers and wait for running writes to finish before creating the checkpoint (like fsfreeze suggested by Diego F. Durán).

The main issue with snapshots are the applications that write to storage that are running at the time . What state are they in? To be sure of a snapshot you need to be able to quiesce your writing applications before you take the snapshot. Although Linux via LVM or fsfreeze can manage the OS, you are in no way guaranteed that the write operation you have paused is not part of a larger batch of writes that will half written in your backup.

Some databases may be able to recover from this by replaying the transaction log if both log and data are in the same snapshot, but most other applications aren't that capable.

share|improve this answer

Just freeze the filesystem contained in the volume using fsfreeze before taking the snapshot and unfreeze it after it's finished.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.