25 July, 2010

Delete all snapshots by name (XenServer)

I posted a blog a while back on how to delete all snapshots from SR.
I found it not working 100%, so I wrote a new script that deletes all Snapshots by name.
So if you use the backup script I wrote you can use this as a pre-step to delete old snapshots.

Here it is:
====================================================

echo === deleting old snapshot ===
set user=[user]
set password=[password]
set server=[IP]
echo Start at:
echo %date% - %time%
:start
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% template-list name-label=4Backup --minimal > Old_tempates.txt
for /f "tokens=1 delims=," %%G in (Old_tempates.txt) do (
if [%%G] EQU [] (goto end) else (
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% template-param-set is-a-template=false uuid=%%G
C:\Progra~1\Citrix\XenCenter\xe.exe -s %server% -u %user% -pw %Password% vm-uninstall uuid=%%G force=true
goto start
)
)

:end
=================================================

enjoy...

No comments:

Post a Comment