Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Writing a script to hibernate Windows VM and copy vdisk as backup

Featured Replies

Hello,

 

I've tried to find the answer by googling a bit but I can't seem to find anything helpful. I wanted to write a script to do the following, but I'm not well versed in terminal commands on Linux and especially with dealing with VMs:

 

The general goal is to automate vdisk backups on a schedule.

 

1. Hibernate Windows VM running. Lets call this VM WinMain.

2. Copy vdisk of Windows VM to a temporary folder on cache (VM lives on cache), lets call this folder VMTemp.

3. Boot copied vdisk using another template setup called WinBackup. This VM template always assumes the same folder path and vdisk name. (All VMs have one vdisk named vdisk).

4. Shutdown VMBackup. This is to have the copied vdisk in a fully shutdown state instead of hibernated.

5. Move copied vdisk to backup folder on array.

6. Rename vdisk to include backup date e.g. vdisk_yyy-mm-dd

7. Repeat steps 1-6 for all Windows VMs present. I assume I can run some sort of for loop for this.

8. Run a cleaning process to keep last n copies.

9. Resume any VMs that were active but hibernate for this process.

 

XML copy along with vdisk copy would also be helpful, but not top priority as I don't change the XML once a VM is running and in use, and I usually copy and date the XML to backup folder on the array.

 

Steps 1, 3 and 4 are the troublesome ones for me, especially how to send a hibernate/boot/shutdown command via terminal/CLI, I can't seem to find an answer despite unRAID providing a button for hibernate in the GUI. I have qemu installed on Windows, and I do hibernate Windows both from within the VM and through unRAID GUI regurarly. I also want to be able to have some sort of wait and check for the hibernate/boot/shutdown, and have something like a 5 minute wait otherwise force shutdown in there, with a log that's written on whether the process was successful or if force shutdown needed to be invoked, maybe with a notification popup on the unRAID GUI as I monitor that frequently.

 

The rest of the steps I can probably figure out, but if anyone is nice enough to provide help for the entire process that'd be awesome.

 

Thanks in advance for any help.

 

Thought I'd mention that the reason for this is that in case of something like an update screwing up the VM, I can quickly get back up and running using a prior save.

Edited by Serpentyne

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.