11 May, 2010

Delete all snapshots in a SR (XenServer)

Hi,

Wrote a little script to centrally delete all snapshots from a SR on XenServer.
I noticed that although you delete a snapshot an entry still remains on the SR.
Since I have 1 main SR I wrote a script to delete all of them before the backup process begins (later when it will be ready I'll post it).

================================================
echo === deleting old snapshot ===
echo Start at:
echo %date% - %time%
:start
C:\Progra~1\Citrix\XenCenter\xe.exe -s [Pool Master / Server IP] -u [user] -pw [password] vdi-list is-a-snapshot=true sr-uuid=[sr uuid] --minimal > vdi.txt
for /f "tokens=1 delims=," %%G in (vdi.txt) do (
if [%%G] EQU [] goto end
C:\Progra~1\Citrix\XenCenter\xe.exe -s [Pool Master / Server IP] -u [user] -pw [password] vdi-destroy uuid=%%G
echo.
goto start
)

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

and it works great...

No comments:

Post a Comment