LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 06-25-2015, 01:34 PM   #1
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Rep: Reputation: 37
Making sure I'm backing up QEMU/KVM image correctly (when not live)


Quick background: after having the physical computer running my home networking stack fail a couple times, I wanted to run a VM so that I could still have DNS/file server/MYSQL/etc even if the hardware fails. And I wanted to have software backups in case an upgrade borks this (another problem I've had).

So, I want to make sure this is going to work correctly. Doing it live seems overly complicated what with LVM and all that. But that's OK, I already have a time it needs to be off - when upgrading the kernel. So I was figuring instead of a reboot, I'll shut it off for a minute or two and copy off a backup. The backup being the hard drive and the XML.

I started Googling and it turns out there's this whole sparse files thing to worry about.

I just want to make a backup that's going to work if something goes wrong either on the hardware or the OS.

What do I need to do? I've seen some stuff about needing to tar it up with the --sparse command or something.
 
Old 06-25-2015, 02:04 PM   #2
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,493

Rep: Reputation: Disabled
This may help.
https://administratosphere.wordpress...t-why-and-how/
 
Old 06-25-2015, 02:23 PM   #3
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Original Poster
Rep: Reputation: 37
It certainly agrees with what I've seen when Googling around. Am I interpreting this and other sources correctly in that the only "bad" thing that can happen is that a cp or a backup will copy a full-sized file? No corruption or anything, just a larger file to backup/copy/etc? That's OK with me. My VM in question is only 10GB if completely full anyway.
 
Old 08-20-2015, 02:29 PM   #4
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Original Poster
Rep: Reputation: 37
I've created a bash script that I'll link to in a few minutes when I get home (as long as I remember to do so). On the plus side because the VM is mostly 0s, when I gzip it, it goes from 10GB to 700MB.
 
Old 08-20-2015, 04:14 PM   #5
DJOtaku
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora 25;CentOS 7; Kubuntu; Debian
Posts: 860

Original Poster
Rep: Reputation: 37
Here's my script:

Code:
!#/bin/bash

today=$(date +%m-%d-%Y)

echo "Shutting down BabyLuigi"

virsh shutdown BabyLuigi

echo "Copying the main drive"

cp /var/lib/libvirt/images/BabyLuigi.qcow2 /root/BabyLuigi_Backups/current

echo "Copying the XML"

virsh dumpxml BabyLuigi > /root/BabyLuigi_Backups/current/BabyLuigi_backup.xml

echo "Tarring it Up"

tar cvzf /root/BabyLuigi_Backups/BabyLuigi$today.tar.gz /root/BabyLuigi_Backups/current/

echo "Cleaning /root/BabyLuigi_Backups/current directory"

rm /root/BabyLuigi_Backups/current/*

echo "Starting BabyLuigi back up"

virsh start BabyLuigi
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Set up qemu-kvm-1.0+noroms as spice enabled qemu server vs qemu-kvm-spice on Ubuntu Precise LXer Syndicated Linux News 0 05-26-2012 07:41 AM
kvm-qemu-img: qcow2 disk image format changes to raw format in RHEL-KVM 5.6 rajivdp Linux - Virtualization and Cloud 2 09-19-2011 11:23 AM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization and Cloud 2 03-21-2011 02:05 PM
LXer: Attempt of qemu-kvm-0.14 patching via Gerd’s Hoffmann “spice/qxl: locking fix for qemu-kvm” on LXer Syndicated Linux News 0 03-14-2011 01:20 PM
Using qemu-kvm image to boot my pc luvshines Linux - Virtualization and Cloud 3 03-01-2010 01:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 06:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration