PowerShell script exchange
Post Reply
KFM
Service Provider
Posts: 13
Liked: 2 times
Joined: May 14, 2013 1:46 am
Full Name: KFM
Contact:

Get Restore Point Folder

Post by KFM »

Hi,

I'm wondering how do I programmatically (i.e. PowerShell) get the folder path for each restore point?

Basically I want to achieve as PowerShell output (which I can pipe to CSV or Out-GridView etc) the same thing as this screenshot:

Image

I just cannot piece it together using a combination of Get-VBRRestorePoint, Get-VBRBackup, Get-VBRBackupRepository cmdlets. I've tried seeing if there is some cross-reference to a SoBR extent or even if the folder path is a simple property in the output of Get-VBRRestorePoint cmdlet. I can't find how to get the actual repository extent (it's in a SoBR) nor the Folder property. If I can get the repository extent and the folder path then I can just build the full path to the restore point.

This way for each restore point I can easily see where it is located rather than clicking through a GUI. We currently use SoBR across many extents and to be able to see quickly where each restore point is located is very valuable, especially when manually deleting/reconciling restore point data.


Thanks in advance,
Kam
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Get Restore Point Folder

Post by tdewin »

Got this question from a customer of mine as well. It is possible via unsupported dotnet calls but we decided to just directly query the DB because of the complexity

However, querying the DB is totally not supported and you should be very careful when you install new versions of the software. The database structure might changes and thus the underlying queries might break. Also, do notice that to do this, it is strongly recommended to make a readonly account so that you are sure no changes will ever be made. In our case, we made a sql user but do notice that on a default install, the database will not allow sql authentication.

That being said, I wrapped the queries in some powershell code that you can find on VeeamHub. Again VeeamHub is community driven and not by Veeam R&D nor did it get tested by QA. Stuff is released under MIT License. Basically if it breaks something, well though luck. Again, that's why it is highly recommended to make a readonly account. It would be great to get some feedback since the wrapped queries, since they were only tested in my home lab (9.5u3)

So to get the module, you can execute this:

Code: Select all

iex (wget http://veeamhub.io/veeamhubmodule/bootstrap.txt).content
Make sure to install the latest (not the default stable branch)
Welcome to the VeeamHub Module Bootstrap Installer
################################################################################
Copyright (c) 2018 VeeamHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
################################################################################
Before we continue, please take notice that this module is released under MIT License
Basically, this module is released in an opensource module, but we do not take any responsibility in any case
Do you agree to this before installing?
Write yes to confirm : yes
################################################################################
Fetching version
Which version do you want to install?
stable (default) / latest / <version> / list: latest
Installing latest - Latest master branch release
################################################################################
Do you want to install for this user, or for all users?
user (default) / all (need to be admin):
Installing for user
################################################################################
Installing in C:\Users\Administrator\Documents\WindowsPowerShell\Modules\VeeamHubModule
Seems there is already a version installed, do you want to overwrite?
yes / no: yes
################################################################################
Downloading from https://raw.githubusercontent.com/veeamhub/powershell
Downloading https://raw.githubusercontent.com/veeam ... odule.psd1
> C:\Users\Administrator\Documents\WindowsPowerShell\Modules\VeeamHubModule\veeamhubmodule.psd1
Downloading https://raw.githubusercontent.com/veeam ... odule.psm1
> C:\Users\Administrator\Documents\WindowsPowerShell\Modules\VeeamHubModule\veeamhubmodule.psm1
Installed and loaded 0.0.3
Next time, please use 'import-module VeeamHubModule' to load the module

Now you can use the module. I'm using -SQLPlainTextPassword here but probably you want to use -SQLPassword which accepts a secure string

Code: Select all

import-module VeeamHubModule
$conn = New-VHMSQLConnection -SQLLogin veeamquery -SQLPlainTextPassword yourpass -SQLServer localhost -SQLInstance veeamsql2012 -SQLDB VeeamBackup
Get-VHMSQLStoragesOnRepository -VHMSQLConnection $conn | Format-VHMSQLQuery -select 0,8,6,9 -names ID,Server,Repo,Path
Output should be the following (you can pipe this to out-gridview for example). notice that for example SOBR01 and SOBR02 are part of a scale-out cluster called sobr. So this does work for Scale-Out extents as well
ID Server Repo Path
-- ------ ---- ----
d2c4fe81-8364-4229-b396-003bbdce685d This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-05-04T220034.vib
e74f9874-26ef-45ab-881a-0e410250f726 This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-04-29T220034.vib
80448e38-6ae5-4e26-8ea9-148c0d1c56ab This server sobr02 F:\sobr02\lin-sobr\lin1.30D2018-04-30T171244.vib
6d7f50f7-a013-4eb7-8e46-19abac926edc This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-05-18T220033.vib
a944f826-50f5-4a6a-bbce-1a94eaef3d3e This server splitvm E:\splitvm\lin - 192.168.1.182\lin - 192.168.1.182D2018-05-20T220041.vib
ae54e039-9718-4366-8ec3-1b92ecad4630 This server Backup Repository REFS E:\repo01\vbr - vbr.x.local\vbr - vbr.x.localD2018-05-19T220030.vbk
f71201a1-8a4d-47ab-8d05-222049e96eef This server Backup Repository REFS E:\repo01\VeeamAgentUserfc4e4d56-7b5f-5441-ec30-266f442fc496\Agent_Backup_AD_-_AD\Agent Backup AD - AD2018...
7c86240f-85b4-4020-bf91-2619a828cc1b This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-05-24T220019.vib
6f2bf785-ccdc-47d2-8f79-282e7fc86093 This server splitvm E:\splitvm\lin - 192.168.1.182\lin - 192.168.1.182D2018-05-21T220037.vib
85deca70-b035-42dd-b400-3461cc220a97 Backup Repository 1 \\bluebird\vbrbackups\exchange\exchangeD2017-12-11T150652.vbk
1aa036cf-27a4-4be7-aa7d-36336f832b6a This server Backup Repository REFS E:\repo01\vbr - vbr.x.local\vbr - vbr.x.localD2018-05-20T220025.vib
4325c973-7fae-4985-b448-3a84365d3f7a This server Backup Repository REFS E:\repo01\ad\adD2018-04-26T133229.vbk
8fd68963-c6f5-490e-9898-50bcb35ebac7 This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-05-19T220157.vbk
434a6426-7a20-43e8-9b4f-5849dbe44113 This server Backup Repository REFS E:\repo01\ad\adD2018-05-25T170405.vib
16a58569-c37d-41cc-919e-5ce0bf55590e This server splitvm E:\splitvm\lin - 192.168.1.181\lin - 192.168.1.181D2018-05-21T220037.vib
f0df4cd8-4b00-4948-80b9-6467a1e75b32 Backup Repository 1 \\bluebird\vbrbackups\Backup Job AD + Centos\Backup Job AD + CentosD2017-12-11T155948.vib
3aac7eb6-1871-4d03-a863-680ce9341be2 This server splitvm E:\splitvm\lin - 192.168.1.181\lin - 192.168.1.181D2018-05-20T221357.vib
909f53a8-dbf9-4b96-bdbe-691f5fcde246 Backup Repository 1 \\bluebird\vbrbackups\nativescriptD2018-02-26T194950.vbk
3d9bc7e0-6b05-4b6c-8f2b-745489ed8c0e This server Backup Repository REFS E:\repo01\Linux - 192.168.1.139\Linux - 192.168.1.139D2018-02-19T201515.vbk
66908759-1a71-464b-b228-784b5244c586 vac Cloud repository 1 Backup Copy Job 2D2018-03-08T145504.vbk
bae69a82-783f-4079-a162-7bdc51b73d67 This server sobr02 F:\sobr02\lin-sobr\lin1.30D2018-04-30T142340.vib
1f9d40a0-a1e1-4f12-a9c4-7ec5bc7c7d97 This server Backup Repository REFS E:\repo01\vbr - vbr.x.local\vbr - vbr.x.localD2018-05-21T220020.vib
9b2d91da-0eba-44d6-a2b5-8b94730a5686 This server sobr01 F:\sobr01\lin-sobr\lin1.30D2018-04-30T142128.vbk
02b2d00d-5322-431e-a7ab-9074e583f7ef This server splitvm E:\splitvm\lin - 192.168.1.181\lin - 192.168.1.181D2018-05-19T220325.vbk
2a71841a-2ef4-40b3-bbe7-91673b63116d This server Backup Repository REFS E:\repo01\VeeamAgentUserfc4e4d56-7b5f-5441-ec30-266f442fc496\Agent_Backup_AD_-_AD\Agent Backup AD - AD2018...
0c27a590-d4c7-4224-aaf0-935629d1581c This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-04-28T220349.vbk
3b65dee5-c6a5-4bda-8ce7-95d58a162318 This server Backup Repository REFS E:\repo01\Surelinux\SurelinuxD2018-05-16T220035.vib
0bb009e8-766f-41cc-b887-a30f93f16b45 This server Backup Repository REFS E:\repo01\VeeamAgentUserfc4e4d56-7b5f-5441-ec30-266f442fc496\Agent_Backup_AD_-_AD\Agent Backup AD - AD2018...
3155dd40-ea0e-45f6-bcf4-a5955b7f0e28 Backup Repository 1 \\bluebird\vbrbackups\psvmD2018-02-26T193407.vbk
390bffe2-c272-444f-918b-c1c21c150927 This server splitvm E:\splitvm\lin - 192.168.1.182\lin - 192.168.1.182D2018-05-19T220323.vbk
327e203b-5ad5-4cdc-980c-ed2445140ccf Backup Repository 1 \\bluebird\vbrbackups\Backup Job AD + Centos\Backup Job AD + CentosD2017-12-11T154326.vib
c080b894-b42e-4b12-9178-f706b291392c This server Backup Repository REFS E:\repo01\Linux - 192.168.1.139\Linux - 192.168.1.139D2018-03-06T125013.vib
KFM
Service Provider
Posts: 13
Liked: 2 times
Joined: May 14, 2013 1:46 am
Full Name: KFM
Contact:

Re: Get Restore Point Folder

Post by KFM » 2 people like this post

Hi Timothy,

Thanks for getting back to me. I forgot to reply back to this thread saying I've found a much safer option than querying the database. Basically this can be done by using the PowerShell method FindChainRepositories() in the object returned by the Get-VBRRestorePoint cmdlet.

For example:

Code: Select all

$backup = Get-VBRBackup -name "my_backup"
$restorePoints = Get-VBRRestorePoint -Backup $backup

$results =  New-Object system.collections.arraylist

foreach ($restorePoint in $restorePoints) {
    $parentDir = $restorePoint.FindChainRepositories().FriendlyPath

    $object = [PSCustomObject]@{
        filename = $restorePoint.FindStorage().PartialPath.toString()
        repoServer = $restorePoint.GetHost().Name
        repoName = $restorePoint.FindChainRepositories().Name
        fullDir = "$parentDir" + "\" + "$($restorePoint.GetBackup().Path)"
    }
    $results.add($object) > $null
}

$results
You can then run this in a PoSH window and pipe it to Out-GridView :D
Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests