Irregular Expressions

Feb 3 2010   11:20AM GMT

Finding VM snapshots – Part 1

Dan O'Connor Dan O'Connor Profile: Dan O'Connor

Locating VM’s with snapshots on a datastore is easy if you know how to use the find command.

`find /vmfs/volumes/ -type f -name “*00*.vmdk”` Will look through the /vmfs/volumes/ looking for files with names that match the provided pattern.

More specifically the folders those files are stored in is needed.

AWK can be used to just pull that information back, `find /vmfs/volumes/ -type f -name “*00*.vmdk” | awk -F “/” ‘{print $1″/”$2″/”$3″/”$4″/”$5 }’`.  This output is getting useful but we really don’t need to see the same folder over and over again.

`find /vmfs/volumes/ -type f -name “*000*vmdk*” | awk -F “/” ‘{print $1″/”$2″/”$3″/”$4″/”$5 }’ | uniq` will only return the unique results.  Appending a -c to the `uniq` will provide a count of the number of times that pattern appeared.

I am using this command in two ways, first is the `uniq` with out -c  piped to `wc -l` to get a count of all of the vm’s with snapshots.   The second is with`uniq -c` piped to `sort -rn` to give the number of disks that have snap shots in each VM.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: