PowerShell script exchange
Post Reply
mwpreston
Enthusiast
Posts: 73
Liked: 9 times
Joined: May 25, 2010 3:27 pm
Full Name: mike
Contact:

Powershell command to import backups

Post by mwpreston »

Hi,

Wondering if anyone can help me here....I'm looking for the powershell command in order to import a backup file.
What we have is a veeam server setup onsite, and one remotely. We ship the backups to the remote site every night.
On the weekend what I hope to do is automate the task of importing these backups into the veeam server, and run a surebackup job on them...

I have the powershell installed, however the command import-vbrbackup keeps telling me i'm specifying the wrong value for server....not sure what this is supposed to be...

Thanks,
Mike
Gostev
Chief Product Officer
Posts: 31746
Liked: 7250 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Powershell command to import backups

Post by Gostev »

Hi Mike, what command line do you specify?
mwpreston
Enthusiast
Posts: 73
Liked: 9 times
Joined: May 25, 2010 3:27 pm
Full Name: mike
Contact:

Re: Powershell command to import backups

Post by mwpreston »

I've actually got the syntax down for that command now and everything is working....Thanks,
D_M_C
Lurker
Posts: 2
Liked: never
Joined: Mar 20, 2010 5:09 pm
Full Name: David Click
Contact:

Re: Powershell command to import backups

Post by D_M_C »

Mike,

I too am looking to automate the backup imports on remote veeam server to test using SureBackup feature.
Can you post your script? We were hoping that this would be implemented in the newest version but still waiting.

Thanks,
David
mwpreston
Enthusiast
Posts: 73
Liked: 9 times
Joined: May 25, 2010 3:27 pm
Full Name: mike
Contact:

Re: Powershell command to import backups

Post by mwpreston »

Hi,

Here's what I have used thus far, but only have gotten as far as importing the backups.....a good starter for you though...

Code: Select all

Add-PSSnapin VeeamPSSnapin

$vbrServer = Get-VBRServer | where {$_.Type -eq "Local"}
$direct = "H:\"
$file = Get-ChildItem H:\*.vbk | %{$_.Name}
$fullfile = $direct += $file

Import-vbrbackup -server $vbrServer -FileName $fullfile

exit
Hopefully that gets you going. If you ever get it complete post back to this forum, i'd love to have the full script.
UNHStorage
Lurker
Posts: 1
Liked: never
Joined: Apr 13, 2017 3:32 pm
Full Name: Craig Goodspeed
Contact:

Re: Powershell command to import backups

Post by UNHStorage »

I needed to import a large amount of backup files that were in a remote Backup Repository not connected directly to the Veeam server

Here is the script I am using to import individual backup folders and all VBK files in it

Code: Select all

Add-PSSnapin VeeamPSSnapin

$vbrServer = (Get-VBRServer -Name server.domain.local).Name						#FQDN of server that has the directory of files needing to be imported
$direct = "R:\Name_of_Folder\"												#Define Directory location on the remote server
$filePath = Get-ChildItem \\$vbrServer\r$\Name_of_Folder\*.vbk | %{$_.Name}			#Populate the variable with all VBK files needing to be imported from the remote directory
$totalfiles = (Get-ChildItem \\$vbrServer\r$\Name_of_Folder\*.vbk | %{$_.Name}).Count	#Total number of files in the directory
$incre = 0																#Incremental counter variable

ForEach($file in $filePath)
	{
	$fullfile = "$direct" + "$file"											#Combines directory location and file name 
	$incre++															#Increment counter by 1
	Write-Host "Importing backup file $fullfile from $vbrServer file number $incre"		#Displays in terminal window the current file being imported and its position in line
	Import-vbrbackup -server $vbrServer -FileName $fullfile						#Performs import of file
	Write-Host "Successfully imported file $incre of $totalfiles"						#Displays on the screen the file import count.
	}
exit
I am sure there are ways to be more efficient with the PowerShell script, and I look forward to seeing them. But, this script is currently performing the *.vbk file import for a few thousand files that I needed pulled back into the GUI so I am :D right now.
dellock6
VeeaMVP
Posts: 6163
Liked: 1971 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Powershell command to import backups

Post by dellock6 »

Maybe this one can help too:
https://github.com/VeeamHub/powershell/ ... rt-Backups
The code was written with another use case in mind, but the scan and import commands are in there.

Luca
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests