Hello,
i'm trying your script to backup guest.
I thought when the backup was done the script restarted the guest but it is not the case.
could you give me information?
thanks for your script
bye
hey Russel,
first thanks for your answer.
i create guest with the "virt-install" command. does this command define guest in libvirt ?
what is the way to see if a guest is defined? when i do a virsh list --all i can see all my guest.
when i use your script on a running guest, the backup works fine, but the guest is not re started.
thanks again for your script and your answer.
Hey Russel,
it was a mistake from me.
i let the script in my home directory.
after i put it in /usr/local/bin, it works
thanks for your answers and your script
virt-back -p /root/backup/ -b vm132
Traceback (most recent call last):
File "/usr/local/bin/virt-back", line 242, in
if options.backup or options.backupall: backup( domList )
File "/usr/local/bin/virt-back", line 87, in backup
tar.add( disklist[0] ) # we could loop and tar each disk in disklist
IndexError: list index out of range
Creating the VM with "virt-back -v --create vm132" works like a charme. Also see
root@host ~ # virsh 'list'"
Id Name State
5 vm132 running
root@host ~ # virt-back --info-all --verbose
name: invoking name on vm132
name: name returned vm132 on vm132
info: invoking info on vm132
info: info returned [1, 524288L, 524288L, 1, 11680000000L] on vm132
ok, i see: "A snapshot volume only stores the delta (changes) since it was created. This is convenient for a point-in-time, well, snapshot, but if your original data is lost, you can't restore from a snapshot. "
What about first question?
I do many work on your script before :
- I already implement multi-disk support
- support for qcow2 snapshot to minimise the downtime.
- usage "suspend" instead of "shutdown"
- add option to restore a (previously backup) VM
- add ability to migrate a VM (supend, transfer and re-up on another server)
have a look here if you want this full feature version : https://bitbucket.org/guilhemfr/virt-back
himuraken, Today is your lucky day. I have implemented a retention flag for setting the amount of backups to keep when rotating. Please use the latest version of virt-back.
-a amount, --retention=amount
backups to retain [default: 3]
I am using the script and have not had any success in limiting the number of retained backups. This ends up filling up my backup disk (a NAS drive mounted via NFS), so I need to figure out how to resolve it. Here is an example of the command I am using via cron job:
The retention flag is being ignored. (Currently there are 4 backups stored, and if I don't delete them manually, they will stay there.) I am not seeing anything about the rotation in the logfile/syslog:
Sep 3 01:30:01 535-1201a-vm9 CRON[4486]: (root) CMD (/usr/local/bin/virt-back --quiet --backup --date --retention=2 -p /vmimages1/backups scre-ubuntu-log)
Sep 3 01:30:02 535-1201a-vm9 virt-back: invoking shutdown on scre-ubuntu-log
Sep 3 01:30:02 535-1201a-vm9 virt-back: waited 0 seconds for scre-ubuntu-log to shut off
Sep 3 01:30:12 535-1201a-vm9 virt-back: waited 10 seconds for scre-ubuntu-log to shut off
Sep 3 01:30:22 535-1201a-vm9 virt-back: waited 20 seconds for scre-ubuntu-log to shut off
Sep 3 01:30:32 535-1201a-vm9 virt-back: waited 30 seconds for scre-ubuntu-log to shut off
Sep 3 01:30:42 535-1201a-vm9 virt-back: waited 40 seconds for scre-ubuntu-log to shut off
Sep 3 01:30:52 535-1201a-vm9 virt-back: waited 50 seconds for scre-ubuntu-log to shut off
Sep 3 01:31:02 535-1201a-vm9 virt-back: invoking backup for scre-ubuntu-log
Sep 3 01:31:02 535-1201a-vm9 virt-back: copying /vmimages1/img/scre-ubuntu-log.vmdk to /vmimages1/backups/scre-ubuntu-log.vmdk for scre-ubuntu-log
Sep 3 01:32:46 535-1201a-vm9 virt-back: invoking create on scre-ubuntu-log
Sep 3 01:32:50 535-1201a-vm9 virt-back: archiving files for scre-ubuntu-log to /vmimages1/backups/scre-ubuntu-log-2014-09-03.tar.gz
Sep 3 01:32:50 535-1201a-vm9 virt-back: archiving /vmimages1/backups/scre-ubuntu-log.xml for scre-ubuntu-log
Sep 3 01:32:50 535-1201a-vm9 virt-back: archiving /vmimages1/backups/scre-ubuntu-log.vmdk for scre-ubuntu-log
Sep 3 01:52:58 535-1201a-vm9 virt-back: finished backup for scre-ubuntu-log
I would appreciate your help in resolving this. Thanks for this great utility.
Just a guess but I don't think the way I wrote the retention will work with the --date option.
This is because the filenames are always unique. You must choose either to put dates into your filenames and find a different way to perform rotations, or use the --retention flag and let virt-back rotate the files.
root@cypdell1:/home/modias# ./virt-back --backup-all
shutdown: invoking shutdown on oxygen
shutdown: waited 0 seconds for oxygen to shut off
shutdown: waited 10 seconds for oxygen to shut off
backup: Create XML file with configuration of oxygen
backup: invoking backup for oxygen
backup: copy of /var/lib/libvirt/images/oxygen.img to /home/modias/oxygen.img
Traceback (most recent call last):
File "./virt-back", line 531, in
files = backup(dom)
File "./virt-back", line 134, in backup
copytmpFile = join(options.backpath, basename(tmpfile))
File "/usr/lib/python2.7/posixpath.py", line 121, in basename
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
i am running Ubuntu 14.04 LTS - the guest was running with a .img file under /lib/libvirt/images/os.img and a storage drive from a LVM
Hello Russell,
i try your backup script, it seems to be very nice. But one thing is not very well. It use the normal gzip single threaded, that is very slow. I search your script, but python and I don't be friends ;) I don't find where you call gzip. Where can I change your script to use pigz?
Thank You
Hello - is it possible to exclude one (or more) of the disk images associated with a VM? For instance, I have a VM that has two disk images associated with it - one is the OS/Applications and the other is Data. I only want to back up the Data image.
If this is not an option currently, please consider this a feature request. Thank you!
Hi Jennifer, I saw your comments, virt-back will always attempt to backup all disk images related to a particular guest. Excluding disk / devices is currently not supported.
Thanks for the answer on that. I would appreciate if the ability to exclude specific disk images would be supported in a future version. Thanks for this great utility.
Comments
Hello, i'm trying your script to backup guest. I thought when the backup was done the script restarted the guest but it is not the case. could you give me information? thanks for your script bye
Hey Pascal,
The script has intelligence and keeps track of the guests state before backup.
If the guest was running when the backup was initiated then the guest will be started when the procedure completes.
However, if the guest was shut off when the backup was initiated, then the guest will not be started when the backup is finished.
Also make sure that the guest is defined in libvirt:
syntax: virsh define /path/to/dom/xml
example: virsh define /etc/libvirt/qemu/mbison.xml
Let me know if you have any other questions and I'll be glad to troubleshoot further.
hey Russel, first thanks for your answer. i create guest with the "virt-install" command. does this command define guest in libvirt ? what is the way to see if a guest is defined? when i do a virsh list --all i can see all my guest. when i use your script on a running guest, the backup works fine, but the guest is not re started. thanks again for your script and your answer.
Could you try a test for me?
Could you shut off your guest and then try to start it using virt-back?
shutdown
virsh shutdown
start
virt-back --verbose --create
If this doesn't work there might be something wrong...
Hey Russel, it was a mistake from me. i let the script in my home directory. after i put it in /usr/local/bin, it works thanks for your answers and your script
Hey Russel,
something seems to be wrong with your script.
virt-back -p /root/backup/ -b vm132 Traceback (most recent call last): File "/usr/local/bin/virt-back", line 242, in if options.backup or options.backupall: backup( domList ) File "/usr/local/bin/virt-back", line 87, in backup tar.add( disklist[0] ) # we could loop and tar each disk in disklist IndexError: list index out of range
Creating the VM with "virt-back -v --create vm132" works like a charme. Also see
root@host ~ # virsh 'list'"
Id Name State
5 vm132 running
root@host ~ # virt-back --info-all --verbose
name: invoking name on vm132 name: name returned vm132 on vm132 info: invoking info on vm132 info: info returned [1, 524288L, 524288L, 1, 11680000000L] on vm132
Hi Russell,
I was able to successfully backup my VM using your script, but I can't figure out how to restore it. I just rebuild my system and need your help!
Thx
I have written a procedure for restoring a system from a virt-back guest backup.
http://russell.ballestrini.net/virt-back-restoring-from-backups/
I hope this guide will help.
Thanx! How to select for saving not all disks of VM? And what's the difference between an snapshot and ordinary backup?
ok, i see: "A snapshot volume only stores the delta (changes) since it was created. This is convenient for a point-in-time, well, snapshot, but if your original data is lost, you can't restore from a snapshot. " What about first question?
ok, i see
origfile = disklist[0]
that only first drive is being backup.
Yes, my intention was to backup all images. I never got around to it...
I do many work on your script before : - I already implement multi-disk support - support for qcow2 snapshot to minimise the downtime. - usage "suspend" instead of "shutdown" - add option to restore a (previously backup) VM - add ability to migrate a VM (supend, transfer and re-up on another server)
have a look here if you want this full feature version : https://bitbucket.org/guilhemfr/virt-back
(I do pull-request for this...)
virt-back can now backup all attached disk images.
Install the latest version today.
https://bitbucket.org/russellballestrini/virt-back/changeset/b2bc219d6c6a
Excellent script. Works like a charm.
I will make very good use of it.
Great work!
This is awesome; These types of things should just be included out of the box.
Thanks for sharing!
Excellent tool, thanks for making it! I have looked around but I dont seem to find anyway to increase the number of backups to retain. Any tips?
himuraken, Today is your lucky day. I have implemented a retention flag for setting the amount of backups to keep when rotating. Please use the latest version of virt-back.
-a amount, --retention=amount backups to retain [default: 3]
In fact, I did a vim /usr/local/bin/virt-back and found: if path.isfile( tarpath ): # if file exists, rotate 3 versions
Can I just increment rotate 3 to the number of revisions desired?
Thanks!
It would be great if the script would accept a shutdown time limit before it destroys the domain. I always have to increase it in the source.
Thanks again!
Hello,
Thanks for this utility. It is really useful.
I am using the script and have not had any success in limiting the number of retained backups. This ends up filling up my backup disk (a NAS drive mounted via NFS), so I need to figure out how to resolve it. Here is an example of the command I am using via cron job:
The retention flag is being ignored. (Currently there are 4 backups stored, and if I don't delete them manually, they will stay there.) I am not seeing anything about the rotation in the logfile/syslog:
I would appreciate your help in resolving this. Thanks for this great utility.
Hey Jennifer,
Just a guess but I don't think the way I wrote the retention will work with the
--dateoption. This is because the filenames are always unique. You must choose either to put dates into your filenames and find a different way to perform rotations, or use the--retentionflag and letvirt-backrotate the files.OK, thanks, I'll try removing the date option and see if retention works then. Thanks for the quick reply. Will let you know if that works.
Removing the --date option worked. Thanks!
Hello, getting this error:
root@cypdell1:/home/modias# ./virt-back --backup-all shutdown: invoking shutdown on oxygen shutdown: waited 0 seconds for oxygen to shut off shutdown: waited 10 seconds for oxygen to shut off backup: Create XML file with configuration of oxygen backup: invoking backup for oxygen backup: copy of /var/lib/libvirt/images/oxygen.img to /home/modias/oxygen.img Traceback (most recent call last): File "./virt-back", line 531, in files = backup(dom) File "./virt-back", line 134, in backup copytmpFile = join(options.backpath, basename(tmpfile)) File "/usr/lib/python2.7/posixpath.py", line 121, in basename i = p.rfind('/') + 1 AttributeError: 'NoneType' object has no attribute 'rfind'
i am running Ubuntu 14.04 LTS - the guest was running with a .img file under /lib/libvirt/images/os.img and a storage drive from a LVM
You have an LVM partition on the hypervisor mounted on the guest? Virt-back doesn't support that configuration.
Virt-backup without tar.gz at the end?
500Gb VM needs more like 5 hours to USB 3.0 disk
If you don't want to zip the 500G file, use this flag.
Hello Russell, i try your backup script, it seems to be very nice. But one thing is not very well. It use the normal gzip single threaded, that is very slow. I search your script, but python and I don't be friends ;) I don't find where you call gzip. Where can I change your script to use pigz? Thank You
https://bitbucket.org/russellballestrini/virt-back/src/2f3b7a422097966ec2246ea59ced28fe8cb3707d/virt-back?at=default&fileviewer=file-view-default#virt-back-153
Hello - is it possible to exclude one (or more) of the disk images associated with a VM? For instance, I have a VM that has two disk images associated with it - one is the OS/Applications and the other is Data. I only want to back up the Data image.
If this is not an option currently, please consider this a feature request. Thank you!
Just following up on this - not sure if you saw my initial comment regarding excluding certain disk images from backup. Thanks!
Hi Jennifer, I saw your comments, virt-back will always attempt to backup all disk images related to a particular guest. Excluding disk / devices is currently not supported.
Thanks for the answer on that. I would appreciate if the ability to exclude specific disk images would be supported in a future version. Thanks for this great utility.
Thanks for sharing this script! Works like a charm!
Hello! One of the VMs does not start after the backup. How to turn on debug logging level? Thanks!