TMBTC Post

Create Online KVM Backups


KVM VIRTUAL MACHINES BACKUPS

Create Online KVM Backups

2013-04-08
create-online-kvm-backups
Running eCommerce sites, downtime is considered a bad deal... at the same time, not having backups is even worse. Here is a simple script that I've put together to execute an online backup (not a snapshot) of a Virtual Machine managed by KVM without having to shut down the VM. Create a new file.
$vi snapshot_backup.sh
And copy and paste the following code.
#!/bin/bash
debug=1

function backup_snapshot {
  date=$1
  filename=$2
  if [ `qemu-img info $filename.qcow2 | grep  --count "file format: qcow2"` -eq 1 ] then
    echo "Backing up $filename"
    # create the snapshot
    if [ $debug -eq 1 ] then
      echo "Creating snapshot"
    fi
    qemu-img snapshot -c $date $filename.qcow2
    #copy the snapshot out
    if [ $debug -eq 1 ] then
      echo "Converting snapshot to standalone qcow2 file"
    fi
    qemu-img convert -c -f qcow2 -O qcow2 $filename.qcow2 $filename-$date.qcow2 
    #delete the old snapshot
    if [ $debug -eq 1 ] then
      echo "Deleting snapshot"
    fi
    qemu-img snapshot -d $date $filename.qcow2
  else
    echo "Snapshot backups only support qcow2 files"
 fi
}
date=`date +%d%m%Y`
filename=`echo $1 | sed s/.qcow2//`
backup_snapshot $date $filename
Exit vi, saving the script. Now make your script executable.
$chmod +x snapshot_backup.sh
To run the script pass it the name of your VM.
$./snapshot_backup.sh /path/to/your/vm/hostname.qcow2
From my experience, the performance impact to the VM is fairly minimal. Hope this helps.

WARNING: Make sure to test your backup and recovery mechanisms from time to time.

You might also like
simple-bash-script-to-email-server-status

Simple Bash Script To Email Server Status

2012-08-22

I didn't want to constantly have to log into my servers in order to check on key performance indicators so I decided to write a simple script that would do the checking for me. After collecting results, the script emails them to me. There are a few tools called within the script you might need to install. I also convert any tabs into spaces in order to make sure things line up nicely inside my email. #!/bin/bash SERVER="myserver001" TOEMAIL="admin@myservers.com" FROMEMAIL="myserver001@myserverscom" # Who is logged in and what are they up to WHO=`w` #


Read More...

how-to-fix-pagehandlerfactory-integrated-has-a-bad-module-when-setting-up-asp-net

How to fix: “PageHandlerFactory-Integrated” has a bad module when setting up ASP.NET

2012-08-22

I was recently setting up IIS 7.5 on Windows 2008 R2 for an ASP.NET site and came across the following 500 error: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list. After a bit of searching, it turns out ASP.NET was not completely installed with IIS even though I checked that box in the "Add Feature" dialog. I found a number of suggestions but found this command. It fixed my issues and got rid of the error. %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i For a 32 bit system, use the


Read More...