none
Backing Up Hyper-V Host Cluster with Windows Server Backup RRS feed

  • Question

  • Hi,

    I am thinking about using the Hyper-V VSS writer to perform monthly DR backups of all of my virtual machines to a remote file server and then backing these up with CommVault until they support the VSS writer.

    The problem I have run into is that there is no way of predicting which node a VM might be on at the time of the backup at all times in the future. Is there a good way around this?

    I tried pointing the backup software to a remote computer and entered the cluster name, but this just (predictably) connected me to the cluster node that was currently hosting the network name.

    The best solution I can think of is doing everything on the command line and including cluster commands to enumerate the current node of a VM, move the target VM to one node, perform a backup of its drive letter only and then move it back, but I don't really consider this a good solution.

    Cheers,
    Jeremy.
    Wednesday, November 12, 2008 5:02 AM

Answers

  • Hi!

    As long as you do not have a backup software that supports VSS to backup your VMs directly, you will have to stay with the command line. I have tried this myself and as you I am not really happy with the solution. Here is what I have done:

    1) Check if the disc on which a VM resides is available at the host
    2) if it is use VSS to backup the machine
    3) run this on all hosts

    If you want to run the script only on one node you will have to move the VM to the specific host and then do the backup. This could be a bit tricky because you first have to figure out on which node the VM is running at the moment. I have never done this myself.

    Andreas
    • Marked as answer by Chang Yin Tuesday, November 25, 2008 1:53 AM
    Wednesday, November 12, 2008 6:51 AM
  • Here is the script I ended up writing.  I call a vbs script that returns the drive letter given the volume label.  To get this to work I make sure that the volume label of the LUN for the VM is the same name as the VM and the cluster group name is also the same name as the VM.

    The script accepts two command line arguments.  The first must be the VM name (no spaces).  If you supply a second command line option of OFFLINE, the VM is taken offline prior to backup.  I did this because VMs that must be taken offline to take the snapshot are seen as a failure of the cluster resource.

    @ECHO OFF
    TIME /T > "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    SET VM=%1
    SET MODE=%2
    SET BACKUPDESTINATION=\\CBR-P-NAS-01\SCVMMLibrary$\Backups

    IF [%MODE%]==[OFFLINE] cluster group "%VM%" /OFFLINE >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    REM First we need to determie what node the VM is currently on
    FOR /F "usebackq tokens=1-2" %%a IN (`cluster group "%VM%"`) DO IF [%%a]==[%VM%] SET CURRENTNODE=%%b

    REM Now if the current node isn't this machine then move the VM to this machine
    IF NOT [%COMPUTERNAME%]==[%CURRENTNODE%] cluster group "%VM%" /MOVETO:%COMPUTERNAME% >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"
    TIMEOUT 30

    REM Now get the drive letter of the volume that hosts the VM. Assumes the volume label is the same as the VM
    FOR /F "usebackq" %%f IN (`cscript //nologo "%~dp0ReturnDriveLetterGivenVolumeLabel.vbs" %VM%`) DO SET VOLUME=%%f

    IF NOT EXIST "%BACKUPDESTINATION%\%VM%" MD "%BACKUPDESTINATION%\%VM%"
    WBADMIN START BACKUP -backupTarget:"%BACKUPDESTINATION%\%VM%" -include:%VOLUME% -quiet >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    IF NOT [%COMPUTERNAME%]==[%CURRENTNODE%] cluster group "%VM%" /MOVETO:%CURRENTNODE% >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"
    TIMEOUT 30

    IF [%MODE%]==[OFFLINE] cluster group "%VM%" /ONLINE >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    TIME /T >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    SET VM=
    SET MODE=
    SET BACKUPDESTINATION=
    SET VOLUME=
    SET CURRENTNODE=
    :END

    • Marked as answer by JeremyHagan Tuesday, November 25, 2008 2:38 AM
    • Marked as answer by JeremyHagan Tuesday, November 25, 2008 2:38 AM
    • Marked as answer by JeremyHagan Tuesday, November 25, 2008 2:39 AM
    Tuesday, November 25, 2008 2:38 AM

All replies

  • Hi!

    As long as you do not have a backup software that supports VSS to backup your VMs directly, you will have to stay with the command line. I have tried this myself and as you I am not really happy with the solution. Here is what I have done:

    1) Check if the disc on which a VM resides is available at the host
    2) if it is use VSS to backup the machine
    3) run this on all hosts

    If you want to run the script only on one node you will have to move the VM to the specific host and then do the backup. This could be a bit tricky because you first have to figure out on which node the VM is running at the moment. I have never done this myself.

    Andreas
    • Marked as answer by Chang Yin Tuesday, November 25, 2008 1:53 AM
    Wednesday, November 12, 2008 6:51 AM
  • Here is the script I ended up writing.  I call a vbs script that returns the drive letter given the volume label.  To get this to work I make sure that the volume label of the LUN for the VM is the same name as the VM and the cluster group name is also the same name as the VM.

    The script accepts two command line arguments.  The first must be the VM name (no spaces).  If you supply a second command line option of OFFLINE, the VM is taken offline prior to backup.  I did this because VMs that must be taken offline to take the snapshot are seen as a failure of the cluster resource.

    @ECHO OFF
    TIME /T > "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    SET VM=%1
    SET MODE=%2
    SET BACKUPDESTINATION=\\CBR-P-NAS-01\SCVMMLibrary$\Backups

    IF [%MODE%]==[OFFLINE] cluster group "%VM%" /OFFLINE >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    REM First we need to determie what node the VM is currently on
    FOR /F "usebackq tokens=1-2" %%a IN (`cluster group "%VM%"`) DO IF [%%a]==[%VM%] SET CURRENTNODE=%%b

    REM Now if the current node isn't this machine then move the VM to this machine
    IF NOT [%COMPUTERNAME%]==[%CURRENTNODE%] cluster group "%VM%" /MOVETO:%COMPUTERNAME% >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"
    TIMEOUT 30

    REM Now get the drive letter of the volume that hosts the VM. Assumes the volume label is the same as the VM
    FOR /F "usebackq" %%f IN (`cscript //nologo "%~dp0ReturnDriveLetterGivenVolumeLabel.vbs" %VM%`) DO SET VOLUME=%%f

    IF NOT EXIST "%BACKUPDESTINATION%\%VM%" MD "%BACKUPDESTINATION%\%VM%"
    WBADMIN START BACKUP -backupTarget:"%BACKUPDESTINATION%\%VM%" -include:%VOLUME% -quiet >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    IF NOT [%COMPUTERNAME%]==[%CURRENTNODE%] cluster group "%VM%" /MOVETO:%CURRENTNODE% >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"
    TIMEOUT 30

    IF [%MODE%]==[OFFLINE] cluster group "%VM%" /ONLINE >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    TIME /T >> "%BACKUPDESTINATION%\%VM%\%VM%Backup.log"

    SET VM=
    SET MODE=
    SET BACKUPDESTINATION=
    SET VOLUME=
    SET CURRENTNODE=
    :END

    • Marked as answer by JeremyHagan Tuesday, November 25, 2008 2:38 AM
    • Marked as answer by JeremyHagan Tuesday, November 25, 2008 2:38 AM
    • Marked as answer by JeremyHagan Tuesday, November 25, 2008 2:39 AM
    Tuesday, November 25, 2008 2:38 AM