Follow

Tip: How to Bulk Backup/Edit/Restore Device Settings (or other configuration)

The following are instructions on how to both backup, edit, and restore the rediscovery frequency settings for your devices. This example demonstrates changes with test rediscovery on a device, but can be used more broadly across many other configuration changes. With changes such as these, always use extreme caution and double-check your formulas and results. Please consult with Kaseya Support should there be any questions.

The following are examples done in a Windows Environment, for Linux, please consult the Traverse CLI for modifications:http://traverse.help.kaseya.com/pages/viewpage.action?pageId=1867820

An exhaustive list of the commands may be found in the BVE FlexAPI Developer's Guide at http://help.kaseya.com/webhelp/EN/tv/R8/dev/index.asp#30141.htm

1- In an elevated command prompt, navigate to the utils folder in Traverse 


 

2- Using the bve API, create a backup of all devices and their rediscovery settings using the following command:

bveCLI.pl --host <host> --user <user> --password <password> --exec "device.list" --field devicename,rediscoveryenabled,rediscoveryfrequency --format CSV --output rediscovery-settings-backup.csv

 

 

3- Open File in Excel/Open Office and re-organize top columns by removing # so the columns properly align.

4- Sort the data by the rediscovery enabled column, descending:

 

 

5- Delete all rows that have rediscovery enabled set to false.

6-Replace all instances of the character "," with blank.

 

 

7- Save two instances of this file. One for backup and another for the changes we are going to make.

8-. Insert the following formula in an adjacent clear cell:

 

=CONCATENATE("device.update ""devicename=";B2;""", ""rediscoveryenabled=true"", ""rediscoveryfrequency=10080"" ")

 

 

Note: These functions were performed in Open Office, similar functionality exists in Excel should you choose to use it.

9- Copy/Paste the cell in each row below until you have a formula for every device.

10- Copy the newly created list of device.update commands and save them in a text called enable-rediscovery.txt

 

 

11- Return to the command prompt, run the following script to change the settings of the machines:

bveCLI.pl --host <host> --user <user> --password <password> --input "C:\Path\To\Text\File\enable-rediscovery.txt"

 

 

12- Confirm the changes have been made:

 

bveCLI.pl --host <host> --user <user> --password <password> --exec "device.list" --field devicename,rediscoveryenabled,rediscoveryfrequency

 

 

13- Once proper analysis has been done, we need to revert the changes. Open the backup save file you made in step 7.

14- Insert the following formula in an adjacent clear cell:

 

=CONCATENATE("device.update ""devicename=";B2;""", ""rediscoveryenabled=true"", ""rediscoveryfrequency=";D2;""" ")

 

 

15- Copy/Paste the cell in the cell below until you have a formula for every device.

16- Copy the newly created list of device.update commands and save them in a text called reset-settings.txt

17- Return to the command prompt, run the following script to change the settings of the machines:

 

bveCLI.pl --host <host> --user <user> --password <password> --input "C:\Path\To\Text\File\reset-settings.txt"

 

18- Confirm the changes have been made:

 

bveCLI.pl --host <host> --user <user> --password <password> --exec "device.list" --field devicename,rediscoveryenabled,rediscoveryfrequency
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Cesar Amaya

    Hi,

    For GNU/Linux environment; this small script will read csv. This will read the export of all servers running rediscovery and then you can change them all together.

    code of readcsv.sh :

    #!/bin/bash
    OLDIFS=$IFS
    shopt -s extglob
    rm -f commands.txt
    IFS=","
    while read serial server
     do
        echo "{$server}"
    server="${server##*( )}"
    echo -e 'device.update devicename='$server',rediscoveryEnabled=true,rediscoveryfrequency=1440' >> commands.txt
     done < $1
     IFS=$OLDIFS

     

    1. Get the list of servers

    # ./bveCLI.pl --host <host> --exec "device.list | grep rediscoveryfrequency" --fields devicename --format csv --output file.csv

    example of file:

    # cat file.csv


    # serialnumber, devicename
    "200000", "letsandgo"
    "80018", "Traverse Server"

    2. We execute the script

    # bash readcsv.sh file.csv
    { devicename}
    { "letsandgo"}
    { "Traverse Server"}

    3. Now we can run the new command with the new rediscovery

    # ./bveCLI.pl --host raglan --input commands.txt

    Notes:

    * You have to manually edit the script to change the rediscovery frequency

    * The command 3. will run 1 line error, disregard is by design ( will try to look for deviname=devicename)

Article is closed for comments.