Re: Mounting KVM image

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 12, 2010 at 11:54:12AM -0600, Greg Woods wrote:
> What I really want this for is to be able to restore individual files
> from VM images. I back up my virtual machines with a script that pauses
> the VM, makes a copy of the disk image, resumes the VM, and moves the
> copy to our local mass storage device. Works great except that the only
> way to restore individual files from a backup image prior to this was to
> actually create a VM from the backup image and boot it. That involved a
> lot of manual labor. Works fine when we only have a few test VMs, but if
> we end up with dozens or hundreds of VMs in production, I am going to
> need something more automated. This can be scripted as I expect the
> offset is always going to be the same (or I could be clever and
> calculate it from the output of fdisk, then remount with offset). Even
> better, if we eventually do make the move from Xen to KVM, the same
> techniques should still work.

Greg, I'd be really interested to talk to you (offline if you like)
about whether libguestfs could meet your needs here.  It's completely
designed for this scenario, and there are other users doing very
similar things with it.  It won't break if specifics of the disk
format change, is more secure [if you don't trust your VMs, don't
mount their disks directly on the host], and you can run your scripts
as non-root which should give you more flexibility and less chance to
break things.

To give you an idea, you could restore a directory from script by
doing:

  #!/bin/sh -
  set -e
  disk="$1"
  directory="$2"
  destination="$3"
  guestfish -i "$disk" --ro <<EOT
  tgz-out "$directory" "$destination"
  EOT

For example:

  $ /tmp/test.sh F13x64.img /etc /tmp/etc.tar.gz
  $ ll /tmp/etc.tar.gz 
  -rw-rw-r--. 1 rjones rjones 7571397 Jun 12 19:09 /tmp/etc.tar.gz
  $ tar ztf /tmp/etc.tar.gz | wc -l
  2118
  $ tar ztf /tmp/etc.tar.gz | head -10
  ./
  ./httpd/
  ./httpd/conf.d/
  ./httpd/conf.d/proxy_ajp.conf
  ./httpd/conf.d/mod_dnssd.conf
  ./httpd/conf.d/welcome.conf
  ./httpd/conf.d/README
  ./httpd/conf/
  ./httpd/conf/httpd.conf
  ./httpd/conf/magic

Let me know ...

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux