自动删除VM的旧快照的最佳方法是什么?
如果已经创建了快照,则可以在此Blogpost中获得带有PowerShell脚本的列表:https://next.nutanix.com/how-it-works-22/list-current-snapshots-via-a-a-script-32693
使用该脚本,您有一些指针可以使用CMDLET删除ntnxsnapshot来清理快照
因为我喜欢上面发布的想法此处并更新脚本以自动删除比给定几天更古老的快照。
更改PE-IP,用户名和密码。并将$删除的日子设置为您喜欢的东西。
Connect -NutanixCluster -Server -username admin -password nutanix/4U -Acceptinvalidsslcerts -forceedConnection
$删除以下= 30
$ nutsnaps = get-ntnxsnapshot
$ allnutvms = get-ntnxvm |选择uuid,vmname
foreach($ nutsnaps中的$ snap){
美元
$ snaptime = $ snap.createdtime/1000
$ snapdt =(get-date'1/1/1970')。addmilliseconds($ snaptime)
$ actualsnapdt = $ snapdt.tolocaltime()
$ limit =(get-witte).addays( - $ deleteatdays)
if($ limit -lt $ actualsnapdt){
写入主持人“快照” -Nonewline
写入主持人$ snap.snapshotname-foregroundercolor黄色 - nonewline
写入主持人“在VM上” -NONEWLINE
写入主持人$ vmname-foregroundcolor黄色 - nonewline
写入主持人“创建” -nonewline
写入主持人$ muthatesnapdt -foregroundoggroundColor黄色-NoneWline
写入主持人“在极限之内,不会被删除。”
} 别的 {
写入主持人“快照” -Nonewline
写入主持人$ snap.snapshotname-foregroundcolor红色 - nonewline
写入主持人“在VM上” -NONEWLINE
写入主持人$ vmname -foregroundColor红色 - nonewline
写入主持人“创建” -nonewline
写入主持人$ facealsnapdt-foregroundcolor红色-NoneWline
写宿主“比极限年龄更大,将被删除。”
$ remove = remove ntnxsnapshot -uuid $ snap.uuid
}
}
更新:制作了一个更好的版本,并为其创建了博客文章:https://www.jeroentielen.nl/cleanup-nutanix-snapshots-after-amount-days/
回复
Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">