Snapshot scheduling

LexluetharLexluethar Member Posts: 516
Could someone point me in the right direction for scheduling snapshots in vCenter? I've created a PowerShell script to snapshot virtual machines but what I would like to do is tap into the Scheduled Task portion of vCenter and schedule these snapshots for a time in the future.

I do not want to schedule this locally using a task scheduler in Windows - i want to be able to leverage vCenter's scheduler and schedule these.

Any input would be appreciated!

Comments

  • tbgree00tbgree00 Member Posts: 553 ■■■■□□□□□□
    You can use vCenter Orchestrator to do a snapshot task. I think it comes with every license level and actually has a built in snapshot taker and remover workflow.
    I finally started that blog - www.thomgreene.com
  • LexluetharLexluethar Member Posts: 516
    Thank you for the suggestion - i will take a look at it for sure.
  • scaredoftestsscaredoftests Mod Posts: 2,780 Mod
    vsphere as well..
    Never let your fear decide your fate....
  • LexluetharLexluethar Member Posts: 516
    Sure i know how to do that scaredoftests, the point is to be able to run a script and do it.
  • blargoeblargoe Member Posts: 4,174 ■■■■■■■■■□
    I looked at trying to do it that way before (powercli to a vsphere scheduled task), and I remember there didn't seem to be an intuitive way to do it.

    Here is an article featuring some functions using get-view that should do the trick. I'm actually going to try these myself when I get some time to play around.

    New vCenter Scheduled Tasks with PowerCLI (Part 2) | EnterpriseAdmins.org
    IT guy since 12/00

    Recent: 11/2019 - RHCSA (RHEL 7); 2/2019 - Updated VCP to 6.5 (just a few days before VMware discontinued the re-cert policy...)
    Working on: RHCE/Ansible
    Future: Probably continued Red Hat Immersion, Possibly VCAP Design, or maybe a completely different path. Depends on job demands...
  • scaredoftestsscaredoftests Mod Posts: 2,780 Mod
    OH!!! doh, sorry about that. We use powershell to run scripts. That would be great to 'schedule' it..
    Never let your fear decide your fate....
  • DigitalZeroOneDigitalZeroOne Member Posts: 234 ■■■□□□□□□□
    Lexluethar wrote: »
    I do not want to schedule this locally using a task scheduler in Windows - i want to be able to leverage vCenter's scheduler and schedule these.

    Any input would be appreciated!

    Is there any reason why you don't want to use Windows task scheduler? I use that as the way to run scripts that will repeat. Just curious.
  • LexluetharLexluethar Member Posts: 516
    Because task scheduler would require the script to run locally on a server that is up 24/7. It would also introduce complexity to where someone now has to have access to schedule a task on a server that will run this, you will also probably need a separate task to cleanup stale schedules. Ideally you could run this powershell / powercli script locally on your PC - enter your credentials and it would add that scheduled task to vCenter.

    Trying to get around having to launch vSphere or vCenter every time we want to schedule a snap. We do a lot of work and snaps are requested multiple times a week. if you are already in vSphere great it's easy - if not it's kind of a pain in the arse to load it up and configure it. Sure it's only a few minutes but multiply that by a few dozen times a month.

    Also if you can get it to run locally you can start actually granting non-vSphere admins access to take snapshots so VMware admins can focus on other tasks.

    Thanks for the input blar - i tried the same thing. Looking through the power-cli commands there is not one for scheduling a snap. You can do a lot of other things with the vimautomation.core add-in within powershell but scheduling tasks is not one of them.
  • iBrokeITiBrokeIT Member Posts: 1,318 ■■■■■■■■■□
    Lexluethar wrote: »
    Also if you can get it to run locally you can start actually granting non-vSphere admins access to take snapshots so VMware admins can focus on other tasks.

    Why not create a new role and grant the snapshot requesters access to through the vSphere Web Client to only permission of "create snapshots" on a list pre-approved VMs? Then have a nightly script run against that list of VMs to delete snapshots older than X days. If they need to revert to a snapshot then they can contact a VMware Admin directly.
    2019: GPEN | GCFE | GXPN | GICSP | CySA+ 
    2020: GCIP | GCIA 
    2021: GRID | GDSA | Pentest+ 
    2022: GMON | GDAT
    2023: GREM  | GSE | GCFA

    WGU BS IT-NA | SANS Grad Cert: PT&EH | SANS Grad Cert: ICS Security | SANS Grad Cert: Cyber Defense Ops SANS Grad Cert: Incident Response
  • DigitalZeroOneDigitalZeroOne Member Posts: 234 ■■■□□□□□□□
    I pretty much exclusively use task scheduler to run over a dozen scripts. It's a somewhat dedicated Windows Server (VM) to run scripts, it does some other things as well. There is an account setup with vSphere rights, and the scripts use that account to do all sorts of tasks. IMO, this is the best way to run repetitive scripts.

    After 1 task is setup, it's easy to use that task for other scripts. I have some samples you if want, and it can help get things up and running.
  • LexluetharLexluethar Member Posts: 516
    Good idea brokeit - still thinking on it. Our snaps have to be kept for various lengths of days depending on the need. Most snaps are requested prior to an update and some snaps can be deleted the next day while others might be weeks. I'm not too concerned about snap deletions. I like the idea of just granting a group that type of access though.

    I was thinking that too digitalzero - we have one vm we use for powershell scripts - might use that.
  • iBrokeITiBrokeIT Member Posts: 1,318 ■■■■■■■■■□
    Lexluethar wrote: »
    Our snaps have to be kept for various lengths of days depending on the need. Most snaps are requested prior to an update and some snaps can be deleted the next day while others might be weeks.

    That would not fly in my environment.

    Sounds like you are using snapshots in place of backups which is wrong and goes against VMware best practices. Snapshots are not backups and you start taking a performance hit when they are kept for a long time.

    https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1025279

    My policy is if you need anything to be kept longer than 72 hours, you need a backup and not a snapshot. You do have a backup solution right?
    2019: GPEN | GCFE | GXPN | GICSP | CySA+ 
    2020: GCIP | GCIA 
    2021: GRID | GDSA | Pentest+ 
    2022: GMON | GDAT
    2023: GREM  | GSE | GCFA

    WGU BS IT-NA | SANS Grad Cert: PT&EH | SANS Grad Cert: ICS Security | SANS Grad Cert: Cyber Defense Ops SANS Grad Cert: Incident Response
  • LexluetharLexluethar Member Posts: 516
    Haha yes we use CommVault. We don't use snaps for backup, it's simply used as a time saving mechanism to get a point in time snap of a VM prior to someone running a software update (outside of windows updates).

    CommVault is our primary backup software, backups are done nightly. What we have found though unfortunately is that with CommVault and large servers restores using CommVault can sometimes take a few hours to complete (depends on the size of the server). There are software updates that have hosed servers that I then had to go through and restore with CommVault. This is okay but there have been times with servers larger than 300 GB that restoring has taken a long period of time.

    As for snaps and performance I'm aware of VMware's best practice. I try to keep our environment as clean as possible but sometimes there is no way to get around other groups not wanting snaps removed. I won't keep a snap longer than a few weeks but sometimes that has happen. It's an exception, not a rule. I run audit reports using rvtools monthly to ensure our environment is healthy.

    Trust me if it were up to me the VMware admin snaps wouldn't last beyond what VMware recommends - but all I can do is offer my recommendation.
Sign In or Register to comment.