Jump to content
danioj

unraid-autovmbackup: automate backup of virtual machines in unRAID - v0.4

144 posts in this topic Last Reply

Recommended Posts

 
2) Run the script with the vdisks_to_skip field filled out for one of the vdisks so that only one gets backed up. Then rename the one vdisk you have a backup of and change the VM configuration.


Cheers JTok, went with option two and it seems to be working as intended now.



Sent from my iPhone using Tapatalk

Share this post


Link to post

A bug in your script just saved my bacon!  My pfsense VM crashed and got corrupted and I'd lost all my config backups as I think they were in the same folder where the xml backup is done.

 

Anyway, I luckily spotted that the script had backed up the pfsense VM image file even though I had set it not to!

 

# list of specific vdisks to be skipped. use the full path.
vdisks_to_skip="
/mnt/disks/sm961/domains/Woody/vdisk1.img
"

I didn't want to backup the image as I didn't want my whole network to go down and 'normally' restoring via the config is easy.  Anyway, thanks for the bug as it saved my life.

 

I've now made multiple copies of my config so please feel free to fix the bug - logs attached ;-)

 

20180528_0200_unraid-vmbackup.log

Edited by DZMM
  • Like 1

Share this post


Link to post

Hello folks, 

 

I have been using this to back up a VM, and a recent power outage corrupted the VM.

 

I copied over the img, but that was insufficient to restore the VM.

I assume this means the configuration is damaged, and while I believe that is part of the backup (the xml file?) I am not sure the proper way to utilize that in the restore process.

 

Can someone guide me in properly restoring from the backup?

Share this post


Link to post

Is there a way to shutdown OSX VMs by the script (or remotely in general)? 

as far as I know I cant right now.  i need to cleanly shutdown manually from within or schedule a shutdown just before the script runs.

 

Share this post


Link to post
Is there a way to shutdown OSX VMs by the script (or remotely in general)? 
as far as I know I cant right now.  i need to cleanly shutdown manually from within or schedule a shutdown just before the script runs.
 
Not sure what you're talking about. When I run this script (with the proper settings)....each of my VMs automatically shut down before they backup in sequence.

Recheck your settings in the script....there are MANY settings

Share this post


Link to post

What I mean is that the Windows based VMs do shutdown.  the Apple OS HighSierra and even before , can not. its not working if I try to stop the VM. the only way is to manually shutdown from within the VM (inside the OSX). 

Share this post


Link to post
2 minutes ago, dadarara said:

What I mean is that the Windows based VMs do shutdown.  the Apple OS HighSierra and even before , can not. its not working if I try to stop the VM. the only way is to manually shutdown from within the VM (inside the OSX). 

No idea. I don't use Mac OS. You can try using the force shutdown option in the settings. Other than that, I dunno. Good luck.

Share this post


Link to post

Force shutdown is exactly what he is complaining about. It will be forced after some time if the clean shutdown isn't working. Except from a sheduled shutdown inside the VM i have no idea. I quickly tested it and it doesn't work for me either. Sorry :(

Share this post


Link to post

First thank you for a good script!

 

I hope it is OK to suggest improvements. :) I noticed that with time stamp my backup location quickly ran into space issues. So my suggestion is to add some sort of clean-up before backing up. I have done some google search myself and found this command:

find ./{backup location} -mtime +{days} -type f -delete

Now I am far from being able to edit this script. But it has not held me back from trying to analyse it a bit. But to me it seems like backup location can re-use the backup location already needed to be specified in the script. The amount of days a backup should be kept safe (not deleted) looks like it could be set as a variable too. I don't know if it is possible to use a derivate of this script to only check files backed-up by the script, or maybe just xml and vdi files. Again I am not an expert here. But maybe one out here with the skills can and want to take a look at it? :)

 

/Alphahelix

Share this post


Link to post

Ok I think I have found a way to have the script delete old files. Please correct me if I have pasted the addition a wrong place, or if there is a better way to do this. But here it is:

 

 

autkvmbackup-with deletion.sh

Edited by Alphahelix

Share this post


Link to post
On 10/6/2018 at 8:46 PM, Alphahelix said:

Ok I think I have found a way to have the script delete old files. Please correct me if I have pasted the addition a wrong place, or if there is a better way to do this. But here it is:

 

 

autkvmbackup-with deletion.sh

There's already a variable to cover this

 

Edit: actually 2

 

# default is 0. set this to the number of days backups should be kept. 0 means indefinitely.
number_of_days_to_keep_backups="0"
# default is 0. set this to the number of backups that should be kept. 0 means infinitely.
# WARNING: If VM has multiple vdisks, then they must end in sequential numbers in order to be correctly backed up (i.e. vdisk1.img, vdisk2.img, etc.).
number_of_backups_to_keep="2"

 

Edited by DZMM

Share this post


Link to post
On 11/24/2018 at 6:03 PM, DZMM said:

There's already a variable to cover this

 

Edit: actually 2

 


# default is 0. set this to the number of days backups should be kept. 0 means indefinitely.
number_of_days_to_keep_backups="0"

# default is 0. set this to the number of backups that should be kept. 0 means infinitely.
# WARNING: If VM has multiple vdisks, then they must end in sequential numbers in order to be correctly backed up (i.e. vdisk1.img, vdisk2.img, etc.).
number_of_backups_to_keep="2"

 

I don't seem to be able to find them... I even tried to download the script file again. from https://github.com/danioj/unraid-autovmbackup/blob/master/unraid-autovmbackup-0-4.sh But I could have overseen er newer revision than the 3 year old one from the link.

Share this post


Link to post
On 5/31/2018 at 11:45 AM, DZMM said:

A bug in your script just saved my bacon!  My pfsense VM crashed and got corrupted and I'd lost all my config backups as I think they were in the same folder where the xml backup is done.

 

Anyway, I luckily spotted that the script had backed up the pfsense VM image file even though I had set it not to!

 


# list of specific vdisks to be skipped. use the full path.
vdisks_to_skip="
/mnt/disks/sm961/domains/Woody/vdisk1.img
"

I didn't want to backup the image as I didn't want my whole network to go down and 'normally' restoring via the config is easy.  Anyway, thanks for the bug as it saved my life.

 

I've now made multiple copies of my config so please feel free to fix the bug - logs attached ;-)

 

20180528_0200_unraid-vmbackup.log

 

This is still broken from what i can tell, is this still being maintained?

 

 

Share this post


Link to post
20 minutes ago, Lebowski said:

 

This is still broken from what i can tell, is this still being maintained?

 

 

Nah. I did this and got really sick. My priorities have changed and tbh I have abandoned this. It was a good idea when i had time but even I back up manually now.

Share this post


Link to post

@JTok Took this over it seems, the script works fine but the skip disk is not functioning. 

Share this post


Link to post

So... I honestly I haven't looked at this for more than a few months since it has been working for my needs and my personal life has been rather busy.
However, I did start working on (and am planning to eventually finish) some updates to this script as well as a version that works with btrfs snapshots.
Things have slowed down a little lately, so I've started getting back into these kind of projects. I will take another look at the vdisk skipping, plus I'm working on adding the ability to parse the vdisk names directly from the xml file as well as a few other things.
Unfortunately I don't have a firm timeline right now, but I expect to be able to devote a decent amount of time over the next month or so.

 

-JTok

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now