-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Check the NAS plugged in and then start the backup job
Hey guys!
Is there any possiblity to check the Name of a NAS that is plugged in (NAS1 or NAS2)? I need it because the NAS will be switched every week and on Monday, I want to check if NAS1 or NAS2 is plugged in to start the certain backup job afterwards. Could you please help me? Thanks in advance,
Daniel
Is there any possiblity to check the Name of a NAS that is plugged in (NAS1 or NAS2)? I need it because the NAS will be switched every week and on Monday, I want to check if NAS1 or NAS2 is plugged in to start the certain backup job afterwards. Could you please help me? Thanks in advance,
Daniel
-
- Product Manager
- Posts: 20282
- Liked: 2257 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Check the NAS plugged in and then start the backup job
I’m wondering whether they are added under different drive letters. For instance, NAS#1 can be found under Z:\, meanwhile, NAS#2 under K:\.
If so, the following script is likely to meet your expectations:
Hope this helps.
Thanks.
If so, the following script is likely to meet your expectations:
Code: Select all
Asnp VeeamPSSnapin
$Job1 = Get-VBRJob -name "Name of your first Job"
$Job2 = Get-VBRJob -name "Name of your second Job"
$backupDrive = $null
$VolumeName1 = "Name of your first drive" #For instance, Z:
$VolumeName2 = "Name of your second drive" #For instance, K:
get-wmiobject win32_logicaldisk | % {
if ($_.DeviceID -eq $VolumeName1) {
$backupDrive = $_.DeviceID
Write-Output "$VolumeName1 drive found! The first job will be started"
Start-VBRJob -job $Job1
}
if ($_.DeviceID -eq $VolumeName2) {
$backupDrive = $_.DeviceID
Write-Output "$VolumeName2 drive found!The second job will be started"
Start-VBRJob -job $Job2
}
}
Hope this helps.
Thanks.
-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Thank you for your quick reply! I am surprised that this is so simple code! Would it also be possible to ask for a certain ID or something like that, to be completely sure that it is either NAS1 or NAS2?
To execute this every week on Monday I simply have to create a planning task in Windows, right?
Thanks,
Daniel
To execute this every week on Monday I simply have to create a planning task in Windows, right?
Thanks,
Daniel
-
- Product Manager
- Posts: 20282
- Liked: 2257 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Assuming that they also have different volume names, it might be worth adding a part that will check volume names, as well. Another metrics I can come up with is the Provider Name that is usually represented by DNS name/IP address under which a certain device has been added to Windows system.
Anyway, you might want to run the following command first in order to understand what parameters of Windows volumes can be gotten and checked via PS:
As the result you will get something similar:
Thanks.
Anyway, you might want to run the following command first in order to understand what parameters of Windows volumes can be gotten and checked via PS:
Code: Select all
get-wmiobject win32_logicaldisk
Code: Select all
DeviceID : Z:
DriveType : 4
ProviderName : \\0.0.0.0\share
FreeSpace : 11111111111
Size : 11111111111
VolumeName : Volume
-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Ok, thank you for this hint, but in my case the NAS doesn't consist of a drive letters, it will only be displayed in the network devices. The backup will either be performed under "\\NAS1\backup" or \\NAS2\backup", depending on which NAS is plugged in. Is there a way to solve it this way?
-
- Product Manager
- Posts: 20282
- Liked: 2257 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Check the NAS plugged in and then start the backup job
I still suggest running the command mentioned above to understand how NAS device is represented in your Windows OS and what particular parameters of it can be used later in order to differentiate two appliances.Unfortunately, it’s rather hard to me to speculate about it, since I don’t have any NAS device deployed in my environment and all my tests are based on usage of common CIFS shares.
Thanks.
Yep, Windows Scheduler should answer your requirements.To execute this every week on Monday I simply have to create a planning task in Windows, right?
Thanks.
-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Re: Check the NAS plugged in and then start the backup job
And is there a possibility to make two pings and depending on the successful ping the different jobs will be started? In this case, I wouldn't need to create a mapped network drive that is appearing to others.
Thanks in advance,
Daniel
Thanks in advance,
Daniel
-
- Product Manager
- Posts: 20282
- Liked: 2257 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Check the NAS plugged in and then start the backup job
As far as I’m concerned, it’s Test-Connection that should be utilized in this case. In general, it’s a ping utility analogue:
Hope this helps.
Thanks.
Code: Select all
Asnp VeeamPSSnapin
$Job1 = Get-VBRJob -name "Name of your first Job"
$Job2 = Get-VBRJob -name "Name of your second Job"
$NAS1 = "Name/IP of your first NAS" #Name/IP of your first NAS
$NAS2 = "Name/IP of your second NAS" #Name/IP of your second NAS
If ((Test-Connection -ComputerName $NAS1 -quiet) -eq $True) {
Write-Output "$NAS1 found! The first job will be started"
Start-VBRJob -job $Job1
}
If ((Test-Connection -ComputerName $NAS2 -quiet) -eq $True) {
Write-Output "$NAS2 found!The second job will be started"
Start-VBRJob -job $Job2
}
Hope this helps.
Thanks.
-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Thank you for your help, that's great!!
-
- Product Manager
- Posts: 20282
- Liked: 2257 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Check the NAS plugged in and then start the backup job
You’re welcome. Should any other questions arise, don’t hesitate to let me know. Thanks.
-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Just one question, now I have 3 Jobs for NAS1 and 3 Jobs for NAS2 and I simply want do disable the jobs from the unplugged NAS, can you tell me the line of code? Thanks!
-
- Novice
- Posts: 7
- Liked: 1 time
- Joined: Jul 11, 2013 5:25 am
- Full Name: NESO Admin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Ok I got it, it is just
Code: Select all
$Job6 = Get-VBRJob -name "//name of the job"
$Job6.DisableScheduler() #or $Job6.EnableScheduler()
-
- Product Manager
- Posts: 20282
- Liked: 2257 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Check the NAS plugged in and then start the backup job
Glad that you’ve found the required method. You can also disable three jobs at once:
Thanks.
Code: Select all
$Jobs = Get-VBRJob | ? {($_.name -eq "Backup Job 1") -or ($_.name -eq "Backup Job 2") -or ($_.name -eq "Backup Job 3")}
$Jobs.disablescheduler()
-
- Lurker
- Posts: 1
- Liked: never
- Joined: Sep 26, 2013 1:48 pm
- Full Name: J Delacruz
- Contact:
Re: Check the NAS plugged in and then start the backup job
I know this is an old post, but this is just what I needed!
Who is online
Users browsing this forum: No registered users and 11 guests