PowerShell script exchange
Post Reply
Darkyputz
Enthusiast
Posts: 27
Liked: never
Joined: Feb 16, 2016 7:51 pm
Full Name: Jan Meinecke
Contact:

[MERGED] Veeam Free and password protected share

Post by Darkyputz »

Hello...

I am running into an issue with password protected shares right now and thought i got around it by adding the following net use statement to the script.
But all i get is a functionality that is able to connect to the share and create folders successfully...but when it comes to Start-VBRZip...it seems to fail...no reaction on the vSphere(normally is see changing this and that in the log)
Without the net use part i get access denied on the network share...
Can someone see the culprit right away that i don't see?!

Thx

Code: Select all

...
$unc_user = 'user',
$unc_password = 'password',
...

net use $bk_repository $unc_password /USER:$unc_user 
try  
{
    foreach($vm in $result)
    {
    Write-Host "Backing up vm: $vm"
    $vm_tobackup = Find-VBRViEntity -Name $vm -server (Get-VBRServer -name $vsphere_host)
                        $path_tobackup = $bk_repository + "\" + $vm + "a"
                        Write-Host "Path to backup: $path_tobackup"
    #BACKUP VM
            if(!(Test-Path -Path $path_tobackup ))
            {
                New-Item -ItemType directory -Path $path_tobackup
            }
    $bk_result = Start-VBRZip -Folder $path_tobackup -Entity $vm_tobackup -Compression $bk_compression -autodelete $bk_autodelete
    $aBkResult = $aBkResult + $bk_result
    }

    ###Create the mail report
    $mail_text = $mail_text + "<tr align='center'><b><td>JOB NAME</td><td>START TIME</td><td>END TIME</td><td>DURATION (min.)</td><td>RESULT</td></b></tr>"
    foreach($result in $aBkResult)
    {
    $result_color = ""
    if ($result.result -eq "Success")
    {
    $result_color = "green"
    }
    elseif ($result.result -eq "Warning")
    {
    $result_color = "yellow"
    }
    elseif ($result.result -eq "Failed")
    {
    $result_color = "red"
    }
    $duration = new-timespan –Start $result.CreationTime –End $result.endtime

    $mail_text = $mail_text + "<tr><td>" +$result.JobName+ "</td><td>" +$result.CreationTime+ "</td><td>" +$result.endtime+ "</td><td>" +$duration.TotalMinutes+ "</td><td bgcolor='$result_color'>" +$result.result + "</td></tr>"
    }

    $mail_body = "<html>
    <b>VeeamFree complete backup script report:<br /><br /></b>
    <table border='1'>
    $mail_text
    </table>
    <html>"
    #####

    #Send email report if enabled and 
    if ($mail_send)
    {
    #Write html report
    $mail_body = $mail_body + $mail_result
    $bk_reportemtpy | Out-File $bk_repository\VeeamFreeCBSReportnew.html
    $mail_body | Out-File $bk_repository\VeeamFreeCBSReportnew.html
    if ($result.result -ne "Success")
    {
    $mail_result = send-mailmessage -from $mail_sender -to $mail_recipient -subject "VeeamFree backup report" -bodyashtml $mail_body -smtpServer $mail_smtp
    }
    }  
}
catch [System.Exception] {  
WriteToLog -msg "could not copy backup to remote server... $_.Exception.Message" -type Error  
}
finally {  
net use $bk_repository /delete  
}
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Veeam Free and password protected share

Post by Vitaliy S. »

Hi Jan,

Can you please try a workaround suggested in this topic? See the answers provided above.

Thanks!
Darkyputz
Enthusiast
Posts: 27
Liked: never
Joined: Feb 16, 2016 7:51 pm
Full Name: Jan Meinecke
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Darkyputz »

Will try...was just somewhat hard to find my subject...smile...
Thx for the idea so far
Darkyputz
Enthusiast
Posts: 27
Liked: never
Joined: Feb 16, 2016 7:51 pm
Full Name: Jan Meinecke
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Darkyputz »

Hello again...not sure if i got the suggested solution right...
Can you explain what they did to get it working?!
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Vitaliy S. »

This one:
v.Eremin wrote:A lot of people in this thread said that granting Veeam account as well as Computer account read/write permissions on the given share have helped them to solve the said issue. Thanks
Darkyputz
Enthusiast
Posts: 27
Liked: never
Joined: Feb 16, 2016 7:51 pm
Full Name: Jan Meinecke
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Darkyputz »

Ok...got that...but "Veeam" account ?!?!
Which user is veeam using?! Will not be Veeam as user name or do i miss something here?!
How can i authenticate the Veeam service?!
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Account under which corresponding backup service is executed. Thanks.
Darkyputz
Enthusiast
Posts: 27
Liked: never
Joined: Feb 16, 2016 7:51 pm
Full Name: Jan Meinecke
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Darkyputz »

LOVE YOU GUYS!!!!

Works...so easy that it is embarrassing that i was not seeing it my own...

THX!
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

No worries. So far this has been number one request we got in regarding Start-VBRZip cmdlet enhancements. We're planning to add -NetworkCredentials parameter to the said cmdlet down the road in order to make our customers' lives easier. Thanks.
tomtom
Novice
Posts: 6
Liked: 1 time
Joined: Nov 17, 2016 9:07 pm
Full Name: Tom

Re: Start-VBRZip in Veeam Backup Free Edition

Post by tomtom »

Hello,

unfortunately I seem to be to stupid to get it working with my Synology NAS. I want to Backup directly with the script to a NAS Share called "Backup":

\\10.10.10.5\Backup\

The Backup&Replication Software is installed on a Windows 10 Machine in a Non-Domain (WORKGROUP) where I execute the script in Powershell with admin rights testwise.

The Backup fails due to an access error (username or password is false).

I assume I have to solve these issues according to posts above:

1) Veeam account read/write permissions on the given share
2) Computer account read/write permissions on the given share

I do not know what is meant by that? What is the "Veeam account" and how do I give it permission to the share?
Do I have to map the UNC on the PC in advance?

I created a user on the NAS with the same name of the PC-User logged in (e.g. Tom) and gave the user the same password than on the PC.
This user has the right to access the Backup share but this does not work??

Can someone be so kind to explain this more in depth?

Highly appreciated
tomtom
Novice
Posts: 6
Liked: 1 time
Joined: Nov 17, 2016 9:07 pm
Full Name: Tom

Re: Start-VBRZip in Veeam Backup Free Edition

Post by tomtom » 1 person likes this post

OK, I finally solved the problem myself. If anyone else having this problem, here is the solution:

Change the Veeam services on the backup machine (e.g. PC) that they are not running under "local system account" but under your specific account that has corresponding rights to access (read/write) the NAS. The local system account has no rights to access network destinations.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Correct, by Veeam account we refer to account under which Veeam-specific services are running. Sometimes changing that account does not solve the issue, and additional permissions must be granted to VB&R computer account.

Glad to hear that you're up and running now.

Thanks.
tomtom
Novice
Posts: 6
Liked: 1 time
Joined: Nov 17, 2016 9:07 pm
Full Name: Tom

Re: Start-VBRZip in Veeam Backup Free Edition

Post by tomtom »

->v.Eremin

Thankfully your script makes it easy for newcomers to successfully perform backups ;D Thank you for that!

Can you tell me one more thing in respect of he $Retention date in your script? Is the date stored in the .vbk file or is just processed by B&R software with the next backup?
I ask because I backup the .vbk to a CIFS share and afterwards the same .vbk will be copied by the NAS to an external HDD (rotation) via USB.
So e.g. when I set "Retention" to "Tomorrow" in B&R I assume the .vbk will be deleted on the next day on the CIFS share after creation.
But does this also mean that this particular backup cannot be restored later e.g. after a week when I try to restore a copy of the .vbk stored on a external HDD?
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Is the date stored in the .vbk file or is just processed by B&R software with the next backup?
The backup file itself does not have any time bomb or something. It's backup software that issues remove command when time comes (not with the next backup). Thanks.
tomtom
Novice
Posts: 6
Liked: 1 time
Joined: Nov 17, 2016 9:07 pm
Full Name: Tom

Re: Start-VBRZip in Veeam Backup Free Edition

Post by tomtom »

Ok, thank you. Time Bomb was the term in short I was looking for ;D
sscheller
Novice
Posts: 3
Liked: never
Joined: Nov 30, 2016 12:39 pm
Full Name: Scheller
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by sscheller »

Hi,

have a small question with free version 9.5 and powershell script.

I use the orginal powershell script, but if i input two vms to backup script, first vm gets backuped, but second one gets this error:

Start-VBRZip : Veeam Backup Free Edition does not support of multiple VMs backup. Specify a single VM, or install a
paid product license.

I know about free version can only backup one vm at time.
But the script is working vm after vm.
Any idea?

Big thanks
Bye
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by Vitaliy S. »

You need to invoke Start-VBRZip twice, if you want to back up two or more VMs in the job.
sscheller
Novice
Posts: 3
Liked: never
Joined: Nov 30, 2016 12:39 pm
Full Name: Scheller
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by sscheller »

Could you please explain this?

Where there i a comment inside the script to define multible vms ?

# Names of VMs to backup separated by comma (Mandatory). For instance, $VMNames = “VM1”,”VM2”
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Can you provide the version of the script you're using? Only if you try to backup several VMs simultaneously, should you get the said error. Thanks.
sscheller
Novice
Posts: 3
Liked: never
Joined: Nov 30, 2016 12:39 pm
Full Name: Scheller
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by sscheller »

Hi, i take your script from 3/24/2015 (update)
But i also tried some other scripts.
If i start the script over powershell and the first vm finishs, the error is coming.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Let me try to run my code against version 9.5 and see whether the said error shows up. Thanks.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Checked the script with 9.5 free version, everything has worked as expected. Most likely, you've modified the script somehow, so that it tries to pass several VMs to -Entity parameter of Start-VBRZip commandlet. Thus, the error. Thanks.
ischneider
Novice
Posts: 3
Liked: never
Joined: Jan 04, 2017 12:45 pm
Contact:

[MERGED] Owner of Backup File for Start-VBRZip Shell Command

Post by ischneider »

Veeam Backup & Replication 9.5
Verision .5.0.711
License Free Edition

When using power shell command Start-VBRZip resulting backup files are always created using local administrator's account instead of the account used to run the script / command.
Thus resulting in access denied error for the NAS file system which only knows about domain users.

Has anyone encountered this issue before or knows a solution?

Thanks and Regards,

Ingo
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

I'd say this is an expected behaviour. Backups are always created with the use of account specified as backup service account (under which VB&R related services are running). The account used to run script doesn't play crucial role here.

Thanks.
ischneider
Novice
Posts: 3
Liked: never
Joined: Jan 04, 2017 12:45 pm
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by ischneider »

Well, using Veeam Backup & Replication Console, the backup files will be created for the user starting the console....
That's why I was expecting similar result using command line tool.....

And btw. the Veeam Backup Service is running by a domain user which would be fine to access the NAS....
Which Veeam service would need to be changed to use the expected domain user having proper access rights for the NAS?
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Veeam Backup Service one. Thanks.
solidus
Novice
Posts: 5
Liked: 1 time
Joined: Jan 02, 2017 3:45 pm
Contact:

[MERGED] Veeam Backup encryption

Post by solidus »

Hello,

this is my first post about this product I think is really powerful. Considering the various possibilities I stumbled into powershell script released by Vlad Eremin and I was wandering if someone in this forum has used or is using it

I am going to try it very soon but I am interested in paticular in the encryption feature

Code: Select all

...
$EnableEncryption = $False
...
$EncryptionKey = ""
...
and if someone has tried to use some different method to encrypt the backup files in such a way that non imply put clear-text passwords in the code


thank you!
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Have you seen the corresponding blog post where I elaborated on encryption portion of the script? Thanks.
solidus
Novice
Posts: 5
Liked: 1 time
Joined: Jan 02, 2017 3:45 pm
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by solidus » 1 person likes this post

Hello Vlad, thank you so much for the script that you created, its very useful!

Yes, I was just talking about that, in the encryption portion its demonstrated how to use a password via Read-Host and ConvertFrom-SecureString from a file. In the first case its not so useful to automate in a task scheduler job. In the second case it still requires a txt file containing an encrypted password but it is still easy decriptable

A good way would be that the script gets the credentials from windows password vault... I remember a discussion about that on stackoverflow
http://stackoverflow.com/questions/2910 ... powershell

Ill try to implement it using the windows credential manager APIs with the CredMan.ps1 script
https://gallery.technet.microsoft.com/s ... s-d44c3cde

I was asking if someone has already done that, I searched in the forum but with no results...

Thank you again!
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Start-VBRZip in Veeam Backup Free Edition

Post by veremin »

Personally I haven't tried that (just covered the very basic scenario), and doubt that anyone else has. So, I'd be interested to hear the results of your findings. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests