VMware Cloud Community
wreedctd
Enthusiast
Enthusiast

SQL Query to find all VMs with Snapshots Older than 30 days

Hey guys I see very limited information about quering the SQL DB so I thought I would share.

Here is a SQL Query to find all VMs with Snapshots older than 30 days.  Use if you wish, keep the negative comments to yourself.

Thanks!

Select

    EN.Name as VM_NAME,

    F.NAME AS CLUSTER_NAME,

    S.SNAPSHOT_NAME,

    S.SNAPSHOT_DESC,

    S.CREATE_TIME

From   

    VPX_ENTITY EN

    INNER JOIN VPX_VM V on EN.ID = V.ID

    INNER JOIN VPXV_HOSTS H ON V.HOST_ID = H.HOSTID

    Inner join VPXV_COMPUTE_RESOURCE F on H.FARMID = F.RESOURCEPOOLID

    inner join [VPX_SNAPSHOT] S on S.VM_ID = V.ID

Where create_time < DATEADD (d,-30,getdate())

Order by CREATE_TIME asc

0 Kudos
0 Replies