-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
How would I query backups for the existence of a server?
I would like a powershell function that would query the current backups on disk in the Veeam database for a specific guest name. So I could pass a servername and it would return a job name that holds that guest. Is there an easy way to accomplish this using built-in veeam powershell functions?
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
Try this example:
Thanks.
Code: Select all
Get-VBRJob | where {$_.GetObjectsInJob().name -eq "Name of your VM"} | select name
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
That is on the right track. It returns no jobs unless the VM I pass is specifically included in a selection list. Most times I run backup jobs based on datastores. Also it returns a job where the machine I am passing it is in the exclusion list and not the selection list. Is there a way to make it only return name if the machine is in the "backed up" resources portion of the job?
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
What about this one:
Thanks.
Code: Select all
Get-VBRJob | where {$_.GetViOijs().name -eq "VM Name" -and $_.GetViOijs().Type -eq "Include"} | select name
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
This seems to work the same way as the other (though slower.) I would think maybe I would have to query restore-points in order to find out what VMs were covered by the jobs, since they are done by data-store or by folder. I only say this because I can expand a restore to list out all the VMs that are contained, but can't see anything based on just the job other than the folder or datastore.
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
The example provided above should care only of selection scope, paying no attention to exclusions list. If you want to work with restore points, something like this should be helpful:
Thanks.
Code: Select all
Get-VBRRestorePoint -name "Name of VM" | select {$_.FindSourceJob().name} | Get-Unique
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
There we go. So now I can pass a VM name to the one-liner and it will return the job which holds a backup for that VM. Is there an easy way to use that data to query for the most recent restore-point for that particular VM?
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
You can sort the resulting restore points, using CreationTime parameter:
Thanks.
Code: Select all
Get-VBRRestorePoint -name "VM Name" | sort creationtime -Descending | select -first 1 | select {$_.FindSourceJob().name}
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
OK great! Final question (i think). How would I exclude copy-jobs from the search? All of my copy jobs contain the word "Copy" in them, but I only want to return local backup jobs and not necessarily the copy jobs related to those backup jobs. Thanks again.
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
I'm currently at the office, and don't have console at hand, but feel free to try the following example and see whether it meets your requirements:
Thanks.
Code: Select all
Get-VBRRestorePoint -name "VM Name" | where {$_.FindSourceJob().Type -eq "Backup"} | sort creationtime -Descending | select -first 1 | select {$_.FindSourceJob().name}
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
That one doesn't seem to return any results
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
I think you should replace Type parameter with with JobType one:
Thanks.
Code: Select all
Get-VBRRestorePoint -name "VM Name" | where {$_.FindSourceJob().JobType -eq "Backup"} | sort creationtime -Descending | select -first 1 | select {$_.FindSourceJob().name}
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
Yep, that works now! Thanks!
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
You're welcome. Should other help be needed, don't hesitate to let me know. Thanks.
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
Maybe a silly question but I have the following in my script:
$JobName = Get-VBRRestorePoint -name "$VM" | sort creationtime -Descending | select -first 1 | select {$_.FindSourceJob().name}
Then when I go to insert $JobName in a DB, it inserts "@{$_.FindSourceJob().name=vmds_nas9}" instead of just "vmds_nas9" as I would have expected. How do I just get the JobName without the other garbage? Thanks!
$JobName = Get-VBRRestorePoint -name "$VM" | sort creationtime -Descending | select -first 1 | select {$_.FindSourceJob().name}
Then when I go to insert $JobName in a DB, it inserts "@{$_.FindSourceJob().name=vmds_nas9}" instead of just "vmds_nas9" as I would have expected. How do I just get the JobName without the other garbage? Thanks!
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
Anyone? Just trying to get these values into a string so I can input them into a database.
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
What if instead of using select, you will put just a dot into use:
Otherwise, you can subtract the unnecessary information, working with substring method.
Thanks.
Code: Select all
(Get-VBRRestorePoint -name "$VM" | sort creationtime -Descending | select -first 1).FindSourceJob().name
Thanks.
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
Yea that worked. Thanks
-
- Expert
- Posts: 122
- Liked: 7 times
- Joined: Mar 27, 2012 10:13 pm
- Full Name: Chad Killion
- Contact:
Re: How would I query backups for the existence of a server?
Almost have this just how I want it. It is still returning instances of copy jobs. I think I can eliminate those if I can just exclude any job who's name includes the word "Copy" in it as I have named all the copy jobs that way. The query I am currently using is:
(Get-VBRRestorePoint -name "$VM" | sort creationtime -Descending | select -first 1).FindSourceJob().name
So I just need one more entry where I can deslect anything in the -name field which has the word "Copy" in it.
(Get-VBRRestorePoint -name "$VM" | sort creationtime -Descending | select -first 1).FindSourceJob().name
So I just need one more entry where I can deslect anything in the -name field which has the word "Copy" in it.
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: How would I query backups for the existence of a server?
You can put into use the example that I've shown you previously; the one using JobType parameter:
I'm currently out of the office, thus, typos and code inconsistencies are expected.
Thanks.
Code: Select all
(Get-VBRRestorePoint -name "VM Name" | where {$_.FindSourceJob().JobType -eq "Backup"} | sort creationtime -Descending | select -first 1).FindSourceJob().name
Thanks.
Who is online
Users browsing this forum: No registered users and 13 guests