List backup jobs, reposotory and folder names

PowerShell script exchange

List backup jobs, reposotory and folder names

Veeam Logoby marius roma » Fri Oct 21, 2016 9:38 am

I apologize for the very basic question.
I need to list existing backup jobs and, for each job, the related repository and the name of the folder
Something like:

bckjob001 Bckstorage1 \\storage1\veeam\bckjob001
bckjob002 Bckstorage1 \\storage1\veeam\backup_job_2
bckjob003 Bckstorage2 \\storage2\backup\veeam\bck_job_3_new

and so on.
As you can see, folder names can be different from job names.
Can anybody please help?
regards
Marius
marius roma
Expert
 
Posts: 327
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: List backup jobs, reposotory and folder names

Veeam Logoby v.Eremin » Fri Oct 21, 2016 10:05 am 1 person likes this post

Hi, Marius,

Try the following one-liner:

Code: Select all
Get-VBRJob | where {$_.JobType -eq "Backup"} | select @{N="Name";E={$_.Name}}, @{N="Repository Name";E={$_.GetTargetRepository().name}}, @{N="Repository Path";E={$_.GetTargetRepository().Path}}| ft -AutoSize


Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List backup jobs, reposotory and folder names

Veeam Logoby marius roma » Fri Oct 21, 2016 11:13 am

Many, many thanks.
Let me ask for a further help.
Is it possible to get the full folder name as well?
Let me explain: if I create a job whose name is "Backup_job_001" the files are saved in a folder whose name is "\\storage1\veeam\Backup_job_001".
If for any reason I rename the job so that the new name is "Backup_job_Finance" I will have a job whose name is ""Backup_job_Finance" writing on folder "\\storage1\veeam\Backup_job_001".
Is is possible to ghet the full folder name, in the example "\\storage1\veeam\Backup_job_001"?
Regards
marius
marius roma
Expert
 
Posts: 327
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: List backup jobs, reposotory and folder names

Veeam Logoby v.Eremin » Fri Oct 21, 2016 11:40 am 1 person likes this post

Just combine a name with a repository path, and you're good to go:

Code: Select all
Get-VBRJob | where {$_.JobType -eq "Backup"} | select @{N="Name";E={$_.Name}}, @{N="Repository Name";E={$_.GetTargetRepository().name}}, @{N="Full Path";E={$_.GetTargetRepository().Path + "\" + $_.Name}} | ft -AutoSize


Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List backup jobs, reposotory and folder names

Veeam Logoby marius roma » Fri Oct 21, 2016 2:31 pm

Thank you for your message.
The problem is that the path can be different from the job name, so job "Backup_job_Finance" cam write in folder "\\storage1\veeam\Backup_job_001".
Is there any way to get the real folder name?
Regards
marius
marius roma
Expert
 
Posts: 327
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: List backup jobs, reposotory and folder names

Veeam Logoby v.Eremin » Fri Oct 21, 2016 2:45 pm

Hmm, in this case I think that querying file system, using Get-Item cmdlet is the only option.

The algorithm should be as follows:

1) Find the latest backup for a given backup job.
2) Get its name.
3) Pass a repository directory as well as backup name to Get-Item cmdlet (don't forget to leverage -recurse switch)
4) Once the backup file is found by Get-Item, check its parent directory - it will be the exact information you're after.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List backup jobs, reposotory and folder names

Veeam Logoby Backerupper » Mon Oct 24, 2016 12:22 pm

You could try looking at the backups as opposed to jobs like so:

Code: Select all
Get-VBRBackup | ?{$_.JobType -eq "Backup"} | Select JobName, @{N="Repository Name";E={$_.GetRepositoryName()}}, DirPath
Backerupper
Enthusiast
 
Posts: 43
Liked: 10 times
Joined: Fri Dec 28, 2012 2:32 pm


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests