Jump to content
Welcome to our new Citrix community!
  • 0

Automate snapshot-destroy for snapshots older than X days.


Daniel Agren

Question

5 answers to this question

Recommended Posts

  • 0

Never done that but I would do something like this. I'm not much of a scripter so this

won't work as is, but something like this is what I would shoot for. Get a list

of all of the snapshot uuid's and delete them. You'll have to incorporate time into 

that loop as well. Also, I would throw in some sort of delay between snapshot 

deletions as multiple in a row could cause performance issues. 

 

--Alan-- 

 

mylist = xe snapshot-list -minimal params=snapshot-time 

 

for i in $mylist ; do

   xe snapshot-destroy uuid=$i

done

 

 

Link to comment
  • 0

Uh, yup.  You get just the zulu times for the creation of these snapshots, hence you'd need to also calculate the current date and create the string format for 30 days (or however long you wish) earlier to compare with.  This might help with that calculation: https://linuxconfig.org/addition-and-subtraction-arithmetics-with-linux-date-command

 

You also need to capture the UUID of the snapshot along with its date so that you can associate which snapshot to delete with its UUID:

mylist = xe snapshot-list -minimal params=uuid,snapshot-time

 

and probably set up an array to hold these pairs, so maybe perl or python might be a better way to track all that information.

You can then compare the dates to see if they are less than the current date - 30 days and only then delete the old snapshots that are less than the

comparison date - 30 days.

 

It'd take a bit of effort to put this all together, but it should be possible.

 

-=Tobias

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...