Well like I understand your question, you want to do the following:
- if the file exists, surebackup job should be succesful
- if the file does not exists, surebackup job should fail (maybe logging extra stuff)
In my test setup I put putty in a directory c:\bin\, eg c:\bin\plink.exe. Then I created a powershell wrapper c:\bin\wrapper.ps1 . This one contains:
Code: Select all
<#
accept ssl certif with PsExec.exe -i -s c:\bin\plink 192.168.15.166 (first boot with hang)
https://docs.microsoft.com/en-us/sysinternals/downloads/pstools
#>
param(
$fexist = "/root/hellodarknessmyoldfriend.txt",
$plink = "C:\bin\plink.exe",
$ip = "192.168.1.166",
$username = "root",
$password = "mysecretpassword"
)
write-host "Testing for $fexist @ $ip"
$argplink = @("-v",$ip,"-l", $username, "-pw", $password,"ls $fexist")
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $plink
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $argplink
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
if($stdout.trim() -ne "") {
write-host "File exists"
exit 0
} else {
write-host "Something went wrong, ... dumping $stderr"
$stderr >> c:\bin\log.txt
exit 1
}
I then use the following Test script settings:
Path :
Arguments :
Code: Select all
-ip %vm_ip% -fexist "/root/fakenews.txt"
(where /root/fakenews.txt is the file I want to test)
You can then check the Surebackup logs. They are normally under C:\ProgramData\Veeam\Backup\<JOBNAME>\Job.<JOBNAME>.log e.g. C:\ProgramData\Veeam\Backup\SureBackup_Job_SureLinux\Job.SureBackup_Job_SureLinux.log in my case. You can look for [Console] in the file to look for the "write-host" you do in powershell
Success if the file exists (I tested for /root as you can see)
Code: Select all
[20.02.2018 18:39:03] <19> Info [SureBackup] [surelinux] [ScriptTests] [Console] Testing for /root @ 192.168.15.166
[20.02.2018 18:39:14] <19> Info [SureBackup] [surelinux] [ScriptTests] [Console] File exists
Fail if the file doesn't exists (I tested for /root/fakenews.txt but it doesn't exists on the server)
Code: Select all
[20.02.2018 18:44:04] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Testing for /root/fakenews.txt @ 192.168.15.166
[20.02.2018 18:44:14] <21> Info [SureBackup] [surelinux] [ScriptTests] [Console] Something went wrong, ... dumping Looking up host "192.168.15.166"
[20.02.2018 18:44:14] <21> Info [SureBackup] [surelinux] [ScriptTests] [Console] Connecting to 192.168.15.166 port 22
[20.02.2018 18:44:14] <21> Info [SureBackup] [surelinux] [ScriptTests] [Console] Server version: SSH-2.0-OpenSSH_7.4
[20.02.2018 18:44:14] <21> Info [SureBackup] [surelinux] [ScriptTests] [Console] Using SSH protocol version 2
[20.02.2018 18:44:14] <21> Info [SureBackup] [surelinux] [ScriptTests] [Console] We claim version: SSH-2.0-PuTTY_Release_0.62
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Using Diffie-Hellman with standard group "group14"
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Doing Diffie-Hellman key exchange with hash SHA-1
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Host key fingerprint is:
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] ssh-rsa 2048 e0:ab:d9:77:cd:93:1b:80:4e:3e:bd:30:75:1c:2f:28
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Initialised AES-256 SDCTR client->server encryption
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Initialised HMAC-SHA1 client->server MAC algorithm
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Initialised AES-256 SDCTR server->client encryption
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Initialised HMAC-SHA1 server->client MAC algorithm
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Using username "root".
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Using SSPI from SECUR32.DLL
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Attempting GSSAPI authentication
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] GSSAPI authentication request refused
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Sent password
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Access granted
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Opened channel for session
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Started a shell/command
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Server sent command exit status 2
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] ls: cannot access /root/fakenews.txt: No such file or directory
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console] Disconnected: All channels closed
[20.02.2018 18:44:14] <20> Info [SureBackup] [surelinux] [ScriptTests] [Console]