VMware Cloud Community
esxi1979
Expert
Expert

Script for taking clone of a VM every week.

Hi all,

Can anyone suggest a script for a VM backup with cloning it every week or any better approach for this ?  I found one  PowerCLI: A Simple VM Backup Script - The SLOG – SimonLong/Blog

Anyone has tested it & any better approach that this one ?

6 Replies
esxi1979
Expert
Expert

This works well, But I need to delete the 30 days old vm which are created here as clone as well. How can I do that ?

0 Kudos
LucD
Leadership
Leadership

You need a mechanism to determine how old a specific clone is.

You can do this via the Events, and look for the events that mark the creation of the clone.

Or you could add a Custom Attribute to the clone when it is created.

Once you determined which of the clones are older than 30 days, it is a matter of removing the cloned VMs (Remove-VM -DeletePermanently).


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

esxi1979
Expert
Expert

Thanks Lucd,

I was also looking for option where the Vcenter scheduler does that .. but looks there is no options to give diff name to the clone (say per date) .. Anyone knows anything ?

0 Kudos
esxi1979
Expert
Expert

Hi

   Guru  User Moderators vExpert  

 

My requirement has changed, now i would like the clone to be created & deleted in 24 hr. So everyday backup.... SO clone1.. create clone2, once done delete clone1 ..

Can you Please help in the code

0 Kudos
LucD
Leadership
Leadership

How did you do the scheduling for the previous requirement ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
KiranDPatil
Contributor
Contributor

Well my plan was to keep a cron/schedule  in the windows vcenter server ... & i am going to use the script same as ( i was exploring the VDP but that product looks so much unstable in my initial experiments so far ... also looking at veeam product ..not tried yet )

PowerCLI: A Simple VM Backup Script - The SLOG – SimonLong/Blog

0 Kudos