how to see veeam backups in powershell

This allows you to see veeam backups for a specified server over the last week.

The code

Enter-PSSession yourveeamserver 
Add-PSSnapin VeeamPSSnapIn 
Get-VBRBackupSession | ? JobName -like '*yourtargetserver*' | ? endtime -gt $(get-date).adddays(-7) | 
    select jobname, jobtype, creationtime, endtime, result, state | sort-object -property jobname, endtime | 
    ft -AutoSize 

Explanation

Explaining this a little…..

This line ‘remotes’ to the veeam server. Getting Powershell remoting set-up is another subject. I’d recommend the Powershell help topic about_remote_troubleshooting, if it doesn’t ‘just work’.

Enter-PSSession yourveeamserver 

This loads all the veeam cmdlets into memory

Add-PSSnapin VeeamPSSnapIn 

This line depends on your Veeam job having the name of the server you’re interested in, in the title. You can run a command to show which job backs up which database. I’ll perhaps post that soon.

Get-VBRBackupSession | ? JobName -like '*yourtargetserver*' | ? endtime -gt $(get-date).adddays(-7) | 
    select jobname, jobtype, creationtime, endtime, result, state | sort-object -property jobname, endtime | 
    ft -AutoSize 

veeam doesn't put 'Database was restored' in the errorlog

I’m doing some testing of veeam restores, and I just noticed this.

Whereas normal ‘vanilla’ disk to disk restores report about themselves in the Sqlserver errorlog

2015-09-17 12:07:08.28 spid1028 Starting up database 'my_little_db'.
2015-09-17 12:07:08.29 spid1028 The database 'my_little_db' is marked RESTORING and is in a state that does not allow recovery to be run.
2015-09-17 12:07:08.54 spid1028 Starting up database 'my_little_db'.
2015-09-17 12:07:08.88 spid1028 CHECKDB for database 'my_little_db' finished without errors on 2015-09-16 17:00:01.930 (local time). This is an informational message only; no user action is required.
2015-09-17 12:07:08.88 Backup Restore is complete on database 'my_little_db'. The database is now available.
2015-09-17 12:07:08.89 Backup Database was restored: Database: my_little_db, creation date(time): 2015/07/22(13:56:48), first LSN: 83:4401:37, last LSN: 83:4417:1, number of dump devices: 1, device information: (FILE=1,TYPE=DISK: {'D:mssql_backupmy_little_dbmy_little_dbbackup_2015_09_16_174516_8366043.bak'}). Informational message. No user action required.

…veeam restores only show ancillary messages

2015-09-17 12:04:39.79 spid815 Setting database option SINGLE_USER to ON for database my_little_db.
2015-09-17 12:04:43.11 spid1026 Starting up database 'my_little_db'.
2015-09-17 12:04:43.17 spid1026 CHECKDB for database 'my_little_db' finished without errors on 2015-09-16 17:00:01.930 (local time). This is an informational message only; no user action is required.
2015-09-17 12:04:43.26 spid1025 Setting database option AUTO_CLOSE to OFF for database my_little_db.

This is perhaps more of a feature of VSS then veeam itself.