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

Follow

Comments

1 comment

  • 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.