Kaseya Community

Check Backup Path For Availability

  • I did not see anything posted on this already. I am planning to write a script to routinely check that the backup path specified in BUDR is available, then I will have it create a ticket if not and run it early enough in the day to do something about it if there is a problem. Before I spend time on it has anybody written anything to do this already?

    Legacy Forum Name: Check Backup Path For Availability,
    Legacy Posted By Username: trebligb
  • Okay, I started writing this. I managed to create a SQL view and variable to get hold of the image location since that data is not in any of the stock kaseya views. This part works.

    I have a problem though. Everything I can think of to actually get the data and report on it depends on my ability to access that variable from the IF statement which as far as I can tell is not possible. Am I missing something? Anybody have any genius ideas about how to best approach this?

    I tried to create a managed variable for this but that appears to be more of a macro kind of thing than true variables.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: trebligb
  • I may be slow here, so just keep with me for a second.

    What variable and what IF statement are we talking about here?

    If you need to do an IF check and then another IF check based on the results of the first, you can call a script in the 'then' script.

    But, considering that fact that I'm barely aware of my surroundings at the moment, I'm probably way off the mark.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: LANWorx
  • I'm probably confused myself. But what I am trying to do is check in the if statement "if" a file I write to the backup path exists (the file is written by a previous script). The "then" would be to state everything is peachy and the "else" would be to do the opposite.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: trebligb
  • Is there maybe a better approach I should take on this? I was all proud of myself for getting what I thought was the hard part building the SQL view Smile

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: trebligb


  • Script Name: Forum Help
    Script Description:

    IF Test File In Directory Path
    Parameter 1 : C:\Path\file
    Exists :
    THEN
    Write Script Log Entry
    Parameter 1 : Everything is peachy! Smile
    OS Type : 0
    ELSE
    Write Script Log Entry
    Parameter 1 : Peachy? ...not so much Sad
    OS Type : 0



    Is this what you are trying to do?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: techsquad
  • imagelocsqlview.jpg
    Sort of, the problem is in the IF statement I can't declare the variable I need to actually get to the backup path. If it were the same path on every machine that would work, but I am pulling the actual path out of a SQL view and the only way I know to do that is to use it as a variable.

    I did figure out a interim way to do this that is not as cool.

    Attached is a screen shot of the SQL View

    Summary of steps:
    1. If True
    2. Write a script log entry stating backup installed
    3. Declare the variable #imageloc# which is based on a SQL view I created and pulls the actual path to the image location.
    4. Delete the test file on the image location but continues if it fails. This makes sure an old file from a previous run of the script does not hose the results
    5. write the test file (stop script if this fails). This is the actual test. If the file writes then the backup is probably good to go. If the file does not write then the script stops and step 6 that says the backup is ready to go never happens. If there is insufficient disk space then we are still hosed, but it will tell if the backup path is not writable
    6. write a script log entry stating the backup is ready to go

    I then run a scheduled report each day around noon that has the script log entries in it that the administrator can scan for machines that only have the first entry.

    Next I want to take this further and instead of having the report to look at create an alert/ticket.


    Script Name: Check Backup Drive, write script log
    Script Description:

    IF True
    THEN
    Write Script Log Entry
    Parameter 1 : Backup installed
    OS Type : 0
    Get Variable
    Parameter 1 : 11
    Parameter 2 : dbo.imageloc/imageLoc
    Parameter 3 : imageloc
    OS Type : 0
    Use Credential
    OS Type : 0
    Delete File - (Continue on Fail)
    Parameter 1 : #imageloc#backuptext.txt
    OS Type : 0
    Write File
    Parameter 1 : #imageloc#backuptext.txt
    Parameter 2 : VSASharedFiles\backuptext.txt
    OS Type : 0
    Write Script Log Entry
    Parameter 1 : Backup Installed, Backup Path Is Writable
    OS Type : 0
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: trebligb
  • Can you create a 2 script process? Create the variable for the path in the 1st script.

    That variable is now available to you in the IF statement of the 2nd script to test if the file exists. If the file does not exist, write a log entry and e-mail yourself so you can fix the problem.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: rkniffin