Backup/restore DRS VM affinity/anti-affinity rules - can they be backed up and restored without re-entering manually after DRS disabled?

DRS VM affinity/anti-affinity rules - these are lost when the DRS is off - they can be "listed" via perl or script Toolkit VI to return to manual if necessary.

But can they be backed up / restored through automated methods for easy recovery in case required or accidental deactivation of the DRS? What happens if a user of vCenter turns off instead of the manual setting during operations?

I have over 100 + VM DRS affinity/anti-affinity rules to maintain.

There are indeed several DRS rules related cmdlets in the VITK 1.5.

The following script will save all rules in a .txt file.

$outfile = "C:\rules.txt"
Remove-Item $outfile
$clusterName = 
$rules = get-cluster -Name $clusterName | Get-DrsRule

foreach($rule in $rules){
  $line = (Get-View -Id $rule.ClusterId).Name
  $line += ("," + $rule.Name + "," + $rule.Enabled + "," + $rule.KeepTogether)
  foreach($vmId in $rule.VMIds){
    $line += ("," + (Get-View -Id $vmId).Name)
  }
  $line | Out-File -Append $outfile
}

The reason why we are writing the rules in a .txt file is because the type of 'Solidarity' with the rules can have 2 or more guests defined.

This type of info (variable length table) is impossible to export to a. CSV file.

The 2nd script reads this external file and sets the rules.

$file = "C:\rules.txt"
$rules = Get-Content $file

foreach($rule in $rules){
  $ruleArr = $rule.Split(",")
  if($ruleArr[2] -eq "True"){$rEnabled = $true} else {$rEnabled = $false}
  if($ruleArr[3] -eq "True"){$rTogether = $true} else {$rTogether = $false}
  get-cluster $ruleArr[0] | `
    New-DrsRule -Name $ruleArr[1] -Enabled $rEnabled -KeepTogether $rTogether -VM (Get-VM -Name ($ruleArr[http://4..($ruleArr.Count - 1)|http://4..($ruleArr.Count - 1)]))
}

[The trick used for guests, it's that we select the part of a table with the \[a... scoring b\].

Currently, you will need to run the first script for each cluster separately, but this could be easily adapted to run on all clusters in your VI.

Tags: VMware

Similar Questions

  • Windows Backup & restore leaves gaps in the backup period date ranges

    I noticed that backup & restore leaves gaps in the date ranges displayed on the screen of backup periods under the function to manage the space.  This means that files change during the interval periods have not been saved?  For example, the screen shows currently backups and the following periods:

    Jan 26: 12-18 Mar, 12 GB 10.40

    Apr 04, 12-13 Apr, 12 GB 19.62

    27 April, 12-27 Apr, 12 GB 05.16

    May 06,12 - May 06,12 02.41 GB

    May 27.12 - 17 Jun, 12 GB 03.41

    What is the importance of gaps?

    How can I tell that B & R is fully backup all files that changed since the last backup run?

    How can I varify the 1st backup is a backup full?

    How can I varify that the system image backup is up-to-date?

    I save approximately once a week to a USB external hard drive. I use options "Include a system image" and "Let me choose" to select the files and have selected the option 'keep only the last frame system & minimize the space used '.

    Hello

    Backups are created in sets called backup periods. To maximize your disk space, Windows backup backup all folders selected, the first time it's run and then it only backs up files that are new or have been modified since the last backup was made. Periodically, Windows creates a new, full backup. Each full backup is called in a backup. When you view your backups of files, you can see all the backup periods with date ranges. If you decide to delete backups of files, you should always keep the most recent backup of the file.

    Reference:

    Should what backup settings I use to maximize my disk space? http://Windows.Microsoft.com/en-us/Windows7/what-backup-settings-should-I-use-to-maximize-my-disk-space

    Back up and restore: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/products/features/backup-and-restore

  • back may be a date of System Restore & how do I manually enter

    I would like to do a system restore but only in December dates are listed.  back, I can go with the date and how do I enter that date manually?

    Hello

    Have you checked the box to return more than 5 days to Restore Points in the system restore?

    Read method 1 > Section 4:

    http://www.Vistax64.com/tutorials/76905-System-Restore-how.html

    If you did and you're still in December, can't do anything.

    Restore Points are already created, or they are not.

    You can only manually create a Restore Point for today, not for yesterday or any other previous time, otherwise than for today.

    See you soon.

  • DRS anti-affinity rules

    Hello world

    I want to create anti-affinity rules machine virtual-VM for 4 virtual machines. We use vSphere 4.0 U2 on our environment.

    What would be the number of rules that are created on the DRS Cluster?

    It's 6 rules? What is different now.

    4 VMS = 6 rules (VM1/VM2 VM1/VM3 VM4/VM1, VM2/VM3, VM4/VM2, VM3/VM4)

    gedelar wrote:

    It's 6 rules? What is different now.

    If you upgrade to vSphere 4.1, that one rule would be necessary, but I guess on 4.0, you must create these six different rules.

    http://www.VMware.com/files/PDF/Techpaper/VMW-whats-new-vSphere41-HA.PDF

    "Finally, rules anti-affinity machine VM-virtual can now integrate more than two virtual machines." Here, VMware DRS try remove the virtual machines specified. Users could use this rule to ensure that some virtual machines are always on different physical hosts. »
  • Evacuation and binding affinity rules

    I have a 5.5 ESXi host called ESXi1 in a group of DRS host called "host of ESXi1 group.  No other ESXi host is in this group, but there are 4 other ESXi hosts in the cluster.  I have a VM called 'VM1' in a virtual machine DRS group called "group virtual machine VM1.  No other VMS are in this group of DRS.

    VM1-> "VM1-machine group.

    ESXi1-> "host of ESXi1 group.

    There is a mandatory rule of DRS that says MV in the 'machine VM1 group' working only with ESXi hosts in the 'host ESXi1 group'.  What happens when I try to put ESXi1 host in maintenance mode?  He will be able to evacuate VM1 since there is no other host in the Group VM1 to work?

    Yes. Answer is 100% correct. If configured VM host affinity/anti-affinity rule is ESSENTIAL, it cannot be violated. Same vSphere HA respects the rules of the VM-host must. Even you can not manually migrate this VM1 to another host. Maintenance mode also cannot assess the host. Even if there is imbalance CPU/Memory, DRS will always obey this rule.

    If you want this rule to be flexible, you can configure the same thing as "soft / should" rule. In this case, rule is violated every time that it is absolutely necessary (like MM, HA does not respect this rule, you can manually migrate VM to others, the DRS in a balanced cpu/memory can violet this rule) but notes that in the immediate following invocation of the DRS, DRS will try its best to resolve the violation of the rules.

    To know what are the rules can be honored by vSphere HA:of vSphere HA abreast of the DRS rules of affinity? | vThinkBeyondVM

    Let us know if you need any other clarity.

  • SQL 2012 still on the use of affinity rules

    Hey guys,.

    I use SQL 2012 alwaya time on in a virtual, but so far, it is not configured as best practices and environment I wanted to change that.

    At the moment I have no DRS rules in place so it can happen that two virtual machines running on the same host and it's something I want to avoid.

    However, my big problem is that I only got a SQL license for two hypervisors and best practices talked about four hosts who are needed to achieve my goal.

    Here is what I intend to implement:

    -Affinity rule machine virtual-VM to separate two virtual machines

    -Affinity VM host rule which VM1 MUST run on ESX1

    -Affinity VM host rule that VM2 MUST run on ESX2

    This configuration is a good idea or could / should I do something different?

    What I found that all the features how for example the evacuation and HA should still work?

    There are many more ESX servers in this group and they will be used in the case of an outtage, right?

    Also there is a dev environment that looks the same. I could include the hosts in the same VM-Host affinity rules or should I create new ones?

    BTW. I am using vCenter and ESX 5.5.0.

    Thank you very much!

    See you soon

    Nicolai

    Affinity rules those you intend to sense. These rules will not be those virtual machines to be on the same host most of the time.

    Note:

    1 rule of VM host is configured as "SHOULD", in extreme cases, DRS can break these rules. However, in the next invocation of DRS, DRS will try to resolve the violations.

    2. Note that: when you keep either the host in maintenance (ESX1 or ESX2) mode, you must manually migrate the VM to another host due to the virtual-VM anti rule machine affinity. DRS even in full auto mode, VM will not be migrated automatically. This will apply only if there are only 2 host in the cluster.

    3. Yes, HA should well with that: however HA is not aware of the rules 'EXPECTED' and in the case of host failure it can not respect 'SHOULD' rule.

    4 rule anti-affinite VM - VM can be sensitized HA using the advanced option. Let me know if you want to help with that.

    5. Yes, failure of other hosts in the cluster will be used but please updated on impact due to rules & licenses.

    6. "There is also an environment-dev which looks the same." I did not follow what exactly you mean here:

    7 migration threshold settings DRS is also important.

    8 DRS gives priority to the prevention of violations of anti-affinity rules machine virtual-VM that violations of rules of affinity. (it's just for your info.)

    Nevertheless,.

    1. If ESX1 falls down or affinity rule VM host that VM1 MUST run on ESX1 gets violated: VM1 can be migrated to other hosts in the cluster. As you have no licenses (more than 2) SQL, how it would be dealt with (I'm not very updated on the SQL licenses)

    2 point above applies to the second rule of VM HOST as well.

  • HA and affinity rules & book by Duncan & Frank

    VMware vSphere reading 5 clusters of Duncan & Frank (Pocket v1.0) deepdive, I'm confused.

    On page 212, second paragraph, it says (roughly) VMware HA is not aware of the virtual-VM anti machine affinity rules, and after an HA event may begin on the same host. But on page 215, second paragraph, it says (roughly) HA will not violate the mandatory rules after HA failover.

    This seems to contradict itself.

    I can not type the full section due to copyright.

    Is anyone able to explain it?

    See you soon.

    Hello

    There are two types of rules:

    1. VM - VM affinity rules
    2. VM - host affinity rules

    HA is not aware of the first, machine virtual-VM, so any rule you create here will be ignored by HA.

    Now, for the second, it's a bit more complicated... There are two types of VM - affinity host rules:

    1. Bride aka mandatory
    2. Expected preferential aka

    HA will respect 'must' of the rules, but will be no respect for the rules 'should '.

    That's what means the book.

  • Affinity rules

    What are the "rules of affinity".

    Thank you

    Prashant

    Affinity rules you can define a rule for example that a specific virtual machine only works on a single host (you choose). Or the other way around: one or more virtual machines are not allowed to run on host A & B for example.

    This is often used in combination with license policies.

    Kind regards

    Mario

  • New-DrsRule - anti-affinite rule Max 2 VM

    Hi all

    I use vSphere PowerCli 4.1 for import and export of objects of vSphere and I was wondering if someone could give me the truth about the rules of the anti-Affinity DRS.

    Specifically, if the number of VM limit is always capped at two.

    The reason why I ask this is that when I try to create a rule anti-XXX for three VM from the command line with the following command:

    New-DrsRule-Cluster (Cluster-Get-name $DRSR.cluster)-name DRSR. Name - Enabled $True - KeepTogether $False - VM (VM - Get $DRSR.vms)

    I get the following error:

    New-DrsRule: 26/07/2011-15:30:24 New-DrsRule you must specify 2 or more VMs if KeepTogether option is set and only 2 virtual machines if KeepTogether option is not set.
    Online: 1 character: 12
    + New-DrsRule < < < <-Cluster (Cluster-Get-name $DRSR.cluster)-name DRSR. Name - Enabled $True - KeepTogether $False - VM (VM - Get $DRSR.vms)
    + CategoryInfo: InvalidArgument: (:)) [new DrsRule], VimException)
    + FullyQualifiedErrorId: Client20_ComputeResourceServiceImpl_TryValidateDrsRuleVMCount_InvalidVmCount, VMware.VimAutomation.ViCore.Cmdlets.Commands.NewDrsRule

    However, I am able to create the rule through vCenter.

    What I'm missing here? Is the rule that I create in vCenter not actually applied?

    Did he able to put me in stright?

    Thank you!

    Thank you.

    You are right, the New-DrsRule cmdlet when it is used for an anti-affinite rule limits the number of guests to 2.

    I suspect that this is for historical reasons.

    In environments of pre-version 4.1, I think it was indeed a limitation, even in the vSphere client.

    So yes, I'm afraid that you have to adapt the script to create anti-affinity rules 2 by 2.

    Fortunately, you can use a simple loop nested to create rules.

    Something like this for example

    $vms = "vm1","vm2","vm3","vm4","vm5","vm6"
    
    $j = 1 1..($vms.Count-1) | %{
        $i = $_    ($i - 1)..0 | %{
            New-DrsRule -Cluster (Get-Cluster -Name MyCluster) `        -Name ("Rule" + $j) `        -KeepTogether $false -VM (Get-VM -Name $vms[$i],$vms[$_])
            $j++    }
    }
    
  • iPhone 6 s - 100% carbon copy backup/restore to iTunes - is that possible?

    Hello

    I am trying to find a way to save/restore an iPhone via iTunes installation so that the restoration of places any return on the phone with the same configuration (essentially, an exact clone of the original installation that is being backed up).

    Questions that I met with attempts to use iTunes for backup/restore:

    • Passwords and other security information do not restore.
    • Applications not getting restored
    • WIFI networks not get restored
    • attached randomly do not restore (some, not all).

    iCloud backups solve this problem (sort of).

    • It takes an internet connection takes too long and medium, and you are left without a phone can be used for a period of time, so that the restore process is complete. I'd rather do it via iTunes.
    • Passwords and other security information do not restore.

    Any help please? In the end, I'm looking for a way to backup my phone to a PC and restore it so it looks identical to how it did before the backup.

    For a long time (perhaps in the iPhone 4/5 days?) this process described above works, 100%. Apple changed something in recent years.

    Thank you

    Bob

    The backup does not contain music or apps, because they should be in the media library iTunes on your computer, and if you synchronize right after that the restoration of the backup is then reinstalled. Normally this is done automatically when you perform a restore if you not to interrupt.

    Passwords and health data are only saved if you choose encrypted backup.

    There is no way to make a backup "image" of the phone, but if you use Encrypted and let run until the end, that it will restore everything the way it was.

    See this Apple trick for some details: about backups in iCloud and iTunes - Apple Support

  • 6 s/iOS iPhone 9.3.5 Confusion of backup/restore/synchronize

    I recently needed to backup, delete and restore my 6s more to unlock it by the carrier.

    I downloaded iTunes on my laptop and made a captive backup via iTunes and also a backup over Wi - Fi to ensure against corruption.  According to receipt messages, eventually led both successfully.

    I erased and reset the iPhone and tried to restore from backup in iTunes on my PC.  In the end, I received a message stating that certain elements could not be restored from the backup and would require synchronization.

    Hoping to achieve a 'clean' restoration, I erased and reset the phone again and tried to restore it Wi - Fi, a process not fully understand because it does not seem to be a separate procedure.  It seems to restore part of the phone and the settings and the rest continue to download in the following hours.

    In the hope of "sync" my way out of the long time requirement by it attach to the PC and the synchronization of the purchased and other content including iTunes transferred to my PC during the backup process.  Despite my PC containing all of the content of the phone in iTunes library files, synchronization of the results in a message that the phone has been synched to another iTunes to another PC library which no longer exists.

    I can't be the first person to question why the iPhone and iTunes don't update automatically to recognize each other as current, as the whole purpose for phone synchronization was to restore the phone and the content on the same State after unlocking it by the carrier.  I don't want to remove any content that is saved in my computer, corrupt iTunes library or lose any multimedia content that has been saved and restored but now doesn't exist anywhere else.

    I'm particularly stupid?  Surely others have encountered similar frustrations and most intelligent people I have discovered how to work in the arcane procedures of Apple.  I would be grateful for any helpful guidance that will help me to get my phone back to where it was a few hours before before releasing the carrier.  They of course don't warn you of this potential drawback - or I would have never bothered.

    Thank you in advance to all those who provide useful assistance.

    No, you're not stupid at all. I don't know what happened in your case, but the normal procedure would be to backup on iTunes (forget iCloud, not as good IMO), get your phone unlocked by the carrier and check it, then restore the backup. There are some things that would be included not in the restoration, as photo albums previously synchronized from a computer. You'd have to re-sync those still separately but not much there.

    Try the above, once more and if this does not help, after return with specific details.

  • I'm trying to import and backup/restore/Choose file... / after backup correctly and I see the file, but there is no JSON extension. What can I do?

    I'm trying to import and backup/restore/Choose file... / after backup correctly and I see the file, but there is no JSON extension. What can I do?

    I backed up my favorites using 'import and backup/Backup' on an external HD, installed Windows 10 and went to restore my bookmarks and noticed the file named "Firefox bookmarks-2015-09-04"had no extension and does not work."

    Please advise! Thank you! Sincerely, s

    If you add the .json extension, it works then? Why people who design browsers or extensions them do create files with no extension name, in spite that these extension names are essential to make the files can be restored? I could never understand that.

  • Backup Restore Time Machine: not enough space

    Hi all, I am a neophyte tech so forgive me if I'm not clear. I will try to explain the problem as best I can:

    I have an old MacBook 2009 running Mountain Lion. A few months ago, my brother gave me his old Pro and so my MacBook 2009 fell by the wayside. I used an external hard drive with that old computer as my backup time machine, but as I tried to transfer a lot of documents and photos and update of dropbox and download photos of google and to understand each of these things as I went along, I totally messed up the MacBook. Just... things are weird... nothing was, where it used to be and my photos were gone and Yes, much of this is probably down to me trying to understand a bunch of new programs at once, BUT what I want to do is to restore it to the way it was using a time machine backup.

    So, I googled around and I know when I start it up until I'm supposed to press Ctrl + R and choose the backup that I want, but when it gets to the part where I select a destination and click the only option (the Mac HD), an error message appears with a yellow flag saying "this disc is not enough space to restore your system.

    Now, I don't really know what that means, but what I want to do is to get rid of the current way, this computer is completely and attach it to the way it was when I did the last Time Machine backup.

    Someone help me please... this stuff is so frustrating when I can't figure it out for me and I am sure that there is an easy solution. I read a lot about partitions etc. but I don't know what all of this means that even.

    Thank you in advance!

    Alexandria

    Boot into Recovery now command + R to start. Choose disk utility and erase the boot volume, it should be named Macintosh HD, unless you renamed it. When the erase is quit disk utility and choose to restore from your Time Machine backup. OS X: on OS X Recovery - Apple Support

  • No backup restore

    Recently, I moved from the France to the Germany. I got my I - Phone 5 music, Apps etc for a value of € 250.-(ceux_qui_sont_encore_visibles_dans_I-Tunes-magasin,_bien_que_le_pays_dele_de_magasin_a_changé_depuis_la_ _France_ _vers_ _l'Allemagne_).  During a recent OS update, I made a backup of all the material here on my local computer. It's still there, that the backup has a 29 GB file size. When I restore all my files and applications on the i-Phone (which lasts 4 hours), shows up, but "grey" with "waiting" crushed it. Then, after a few minutes, all miraculously disappears from the i-Phone with a message: "your APPLE ID is only valid for the German I-Tunes store. I'm not sure to be able to understand, why it is not allowed to use purchases paid with a common currency, like a dictionary French / German, an ATV tracker, software remote control for the AR Drone, converter of units of measure, scales, scales, torches, purchased in France, in Germany too. It is the antithesis of the European Community * principle * of common market. I contacted the support 2 times by email, no response. My next step to consider is a formal complaint to the authority for the protection of consumers in the European Union. The overnext is to bring an action.

    As well as to be bound to the account, content, it is also related to the country it was purchased in - content is licensed to Apple to sell on a country by country basis, an item can have a different licensee for different countries.

    A backup of your iTunes purchases (apps, music, movies, etc; or your own music and videos in the applications of music and videos) does not contain a restore iTunes will try to pick them up from this iTunes library. You have not all relevant in this iTunes library, as well as the backup phone that you produce > devices > transfer purchases to copy on the computer and redownloaded the apps (and any other purchase you might once again) of the Bank of France before moving? If the apps are also in the German store, you might be able to re-download them on the store, you can get a message "you already bought it, would you like to download free" when 'buy '. Media (music, movies, etc.) may not be redownloaded in another country, you will have to come back from the backup of your library/downloads you've been track and maintain copy them.

  • HP 50 G backup restore

    Hello

    I have already backed up my HOUSE on my HP 50 G and it now resides on the SD card as

    3D:

    'HOME1 '.

    I had to reset the default calculator due to variable error, I couldn't serve.

    However, how to restore backup 'HOME1' calculator?

    I have checked the 'Restore' function in the manual, but can't find the necessary commands?

    Any help would be appreciated, because it would take ages to have to reinsert all my directories, formulas and variables again.

    See you soon

    FG

    Hi!, Flash_Gordon:

    Welcome to Forum!

    See...

Maybe you are looking for