Backup Configuration for a Device

Scenario Overview

This guide demonstrates how to perform a configuration backup for a network device using the CNC Device Configuration Backup API. The device configuration is backed up to the Crosswork server and stored in the database.

The operation in the following API references is used in this example.

Prerequisites

Before running this example, ensure:

  1. You have obtained an access token. Refer to the 'Getting Started' section for instructions.
  2. The cnc-api-common.sh script is properly configured.
  3. Necessary input and output directories exist for storing and retrieving configuration backup files.

Create Backup Configuration for the Device

Run the script device-config-backup.sh from the example directory to create a backup of the device configuration.

cd cnc-device-config-backup-restore-api-examples;./device-config-backup.sh

Script Details

This script reads input from the device-config-backup.json file located in the input directory. Upon successful execution of backup collection, a new backup point is generated and the output is saved to the device-config-backup.json file in the output directory. For the request payload, user needs to specify the fields in the json payload below: backup_device_input.png

#!/bin/bash
. ./cnc-api-common.sh

device-config-backup() {
    # Assume the CNC JWT has already been obtained by running the get-cnc-jwt.sh script.
    # Read from JWT file and export it as AUTH_TOKEN_HDR
     export_jwt
      
    
    # STEP 1 : Create Device Configuration Template
    # STEP 2 : Store the output in CNC_API_OUTPUT file
      CNC_API_URL=$CNC_DEVICE_CONFIG_API_CTX/v1/schedule-config-backup-job
      CNC_API_INPUT="$PRJ/input/device-config-backup.json"
      CNC_API_OUTPUT="$PRJ/output/device-config-backup.json"
      http_post $CNC_API_URL @$CNC_API_INPUT $CNC_API_OUTPUT
    
}
device-config-backup