VMware Cloud Community
max2479
Enthusiast
Enthusiast

Daily snapshot removal

I can see where I can schedule the daily snapshots but I want to keep only one? How do I remove snapshots that are older then 1 day

> if you found this or any other answer useful please consider allocating points for helpful or correct answers <
Reply
0 Kudos
8 Replies
WessexFan
Hot Shot
Hot Shot

If you are using vCLI, then just edit this script to fit your environment and save it as a .ps1 file --> then set a Windows scheduled task to run it every night.

The scheduled task must call powershell, so it would look something like this :

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\vSphere PowerCli\vim.psc1" "& "C:\Scripts\RemoveSnap1.ps1" yourventersever

good luck!

edit: that is actually NOT the scheduled task, but the .bat file used by the scheduled task to kick off the removal process.. my apologies on that..

VCP5-DCV, CCNA Data Center
max2479
Enthusiast
Enthusiast

Thank you. this might work. what If i have other snapshots that were created by backup software or other manual snapshots that I want to keep?

it will remove those too, correct?

Any way to specify only snapshots to be removed that were created by schedule?

or is there any other way to accomplish this?

> if you found this or any other answer useful please consider allocating points for helpful or correct answers <
Reply
0 Kudos
WessexFan
Hot Shot
Hot Shot

Hi max!

Yes, this will remove all snapshots no matter if they were scheduled or kicked off manually.

Unfortunately, we cannot pick and choose our snapshot removal with this script (or I have not found a way). I just tell my developers that we keep 3 days worth of snapshots and thats it. Perhaps there is someone out there that will allow us to run this on a datacneter with conditions (scheduled versus manual or backup), but I have not found it yet. Please let me know if you do.

Cheers! Hope it helps..

VCP5-DCV, CCNA Data Center
max2479
Enthusiast
Enthusiast

Do you know the way to copy all snapshots to a different datastore before removing them?

> if you found this or any other answer useful please consider allocating points for helpful or correct answers <
Reply
0 Kudos
jcwuerfl
Hot Shot
Hot Shot

Could you just create a scheduled task to remove the old snapshot then just create a new snapshot? so you only have 1 active snapshot at a time?

Reply
0 Kudos
max2479
Enthusiast
Enthusiast

i would but i do not see the schedule task in vcenter to remove the old snapshot... this would be the ideal way...

i am on 4.0

Is it available in 4.1?

> if you found this or any other answer useful please consider allocating points for helpful or correct answers <
Reply
0 Kudos
WessexFan
Hot Shot
Hot Shot

Could you just create a scheduled task to remove the old snapshot then just create a new snapshot? so you only have 1 active snapshot at a time?

If I could I would.. 4.0 doesnt have that option.. hence the script..

VCP5-DCV, CCNA Data Center
Reply
0 Kudos
jcwuerfl
Hot Shot
Hot Shot

Your right 4.1 doesn't either you would have thought you could have schedule that. Please submit an ER if you could.

Reply
0 Kudos