Scheduled file restore

PowerShell script exchange

Scheduled file restore

Veeam Logoby serkantek » Fri May 18, 2018 1:04 am

Hi,

We have a requirement in our company to restore specific files and folder from the most recent backup of a particular production server running Windows Server 2012 R2 to a different server in our development environment running the same OS.

I have been looking through powershell scripts but I am finding it hard to write anything to set the restore location to a different host.
One thing I can think of is to restore the files back onto the production machine to a different drive, then run a robocopy job to move the files to the development server.
I would like to automate the process as much as possible.

What would be the best way of achieving this? And can someone please help with the scripting part :D

Any help would be appreciated.
serkantek
Novice
 
Posts: 7
Liked: never
Joined: Sun Oct 08, 2017 11:23 pm
Full Name: Serkan Tek

Re: Scheduled file restore

Veeam Logoby tdewin » Wed May 23, 2018 6:42 pm

well starting it, there is actually a good script in the manual
Code: Select all
$origfile = "C:\Reports\June.xlsx"
$result = Get-VBRBackup | where {$_.jobname -eq "Job 1"} | Get-VBRRestorePoint | where {$_.name -eq "VM1"} | Sort-Object creationtime -Descending | Select-Object -First 1 | Start-VBRWindowsFileRestore
$flrmountpoint = ($result.MountSession.MountedDevices | ? {$_.DriveLetter -eq (Split-Path -Qualifier $origfile)}).MountPoint
$file = $flrmountpoint + (Split-Path -NoQualifier $origfile)
Copy $file c:\
Stop-VBRWindowsFileRestore $result

https://helpcenter.veeam.com/docs/backu ... tml?ver=95

So if you want to copy out a file with robocopy, you can use instead of copy, your tool and the source file should be in $file. Hope that helps
tdewin
Veeam Software
 
Posts: 1286
Liked: 421 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Scheduled file restore

Veeam Logoby serkantek » Wed May 23, 2018 11:13 pm

Hi tdewin,

Thank you for your assistance. So my only option would be to restore onto the source backup server in a seperate location then copy to remote server (with some sort of tool)?

I have seen this script before but was unsure if I could add to this to specify a remote server as the restore path.

Just a few of questions -
1. How can I specify a different restore destination rather than original backup location. Is it as easy as defining a new variable?

$restorelocation = "E:\Restores"
$flrmountpoint = ($result.MountSession.MountedDevices | ? {$_.DriveLetter -eq (Split-Path -Qualifier $restorelocation)}).MountPoint

2. I need to exclude 3 files in the folder that I would like to restore either from the restore job or the copy job. What would be the best way? To mention the exclusion in $origfile or to mention the exclusion in copy?

3. If I used the Veeam copy function, can I put network a location in the copy job?
Copy $file "\\remoteserver1\d$\restore\files"

Thanks.
serkantek
Novice
 
Posts: 7
Liked: never
Joined: Sun Oct 08, 2017 11:23 pm
Full Name: Serkan Tek


Return to PowerShell



Who is online

Users browsing this forum: ThierryF and 10 guests