Managing the Configuration with Snapshots

About Configuration Management and Snapshots

You can back up and restore your system configuration by exporting and importing configuration archives (snapshots) to and from a local controller-managed folder. By exporting snapshots before and after making configuration changes, you have the ability to roll back configuration changes that were applied between two snapshots.

You can also upload and download the snapshot files to and from a remote server.

Each snapshot action (export, import, rollback, upload, and download) is performed by creating a policy for the action and then triggering the action as a job. Export actions can also be scheduled to run at a future time or periodically. Import, export, and rollback jobs cannot run in parallel. If a job is already running, triggering a new job will fail.

Exporting a Snapshot

Before you begin

If you want to export snapshots according to a schedule, configure a scheduler before configuring the export policy.

Procedure

  Command or Action Purpose
Step 1

configure

Example:

apic1# configure

Enters global configuration mode.

Step 2

[no] snapshot export policy-name

Example:

apic1(config)# snapshot export myExportPolicy 

Creates a policy for exporting snapshots.

Step 3

format {xml | json}

Example:

apic1(config-export)# format json

Specifies the data format for the exported configuration file. The default is

Step 4

(Optional) [no] schedule schedule-name

Example:

apic1(config-export)# schedule EveryEightHours
(Optional)

Specifies an existing scheduler for exporting snapshots.

Step 5

(Optional) [no] target [infra | fabric | tenant-name]

Example:

apic1(config-export)# target tenantExampleCorp
(Optional)

Assigns the target of the export, which can be fabric, infra, a specific tenant, or none. If no target is specified, all configuration information is exported. The default is no target.

Step 6

(Optional) [no] remote path remote-path-name

Example:

apic1(config-export)# remote path myBackupServer
(Optional)

Specifies the name of a configured remote path to which the file will be sent. If no remote path is specified, the file is exported locally to a folder in the controller. The default is no remote path.

Step 7

end

Example:

apic1(config-export)# end

Returns to EXEC mode.

Step 8

trigger snapshot export policy-name

Example:

apic1# trigger snapshot export myExportPolicy

Executes the snapshot export task. If the export policy is configured with a scheduler, this step is unnecessary unless you want an immediate export.

Examples

This example shows how to configure the periodic export of a JSON-format snapshot file for a specific tenant configuration.


apic1# configure
apic1(config)# snapshot export myExportPolicy 
apic1(config-export)# format json
apic1(config-export)# target tenantExampleCorp
apic1(config-export)# schedule EveryEightHours

Importing a Snapshot

Procedure

  Command or Action Purpose
Step 1

configure

Example:

apic1# configure

Enters global configuration mode.

Step 2

[no] snapshot import policy-name

Example:

apic1(config)# snapshot import myImportPolicy 

Creates a policy for importing snapshots.

Step 3

file filename

Example:

apic1(config-import)# file ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz

Specifies the name of the file to be imported.

Step 4

action {merge | replace}

Example:

apic1(config-import)# action replace

Specifies whether the imported configuration settings will be merged with the current settings or whether the imported configuration will completely replace the current configuration.

Step 5

[no] mode {atomic | best-effort}

Example:

apic1(config-import)# mode atomic

Specifies how the import process handles configuration errors when applying the imported settings. The best-effort import mode allows skipping individual configuration errors in the archive, while atomic mode cancels the import upon any configuration error.

Step 6

(Optional) [no] remote path remote-path-name

Example:

apic1(config-import)# remote path myBackupServer
(Optional)

Specifies the name of a configured remote path from which the file will be imported. If no remote path is specified, the file is imported locally from a folder in the controller. The default is no remote path.

Step 7

end

Example:

apic1(config-import)# end

Returns to EXEC mode.

Step 8

trigger snapshot import policy-name

Example:

apic1# trigger snapshot import myImportPolicy

Executes the snapshot import task.

Examples

This example shows how to configure and execute the importing of a snapshot file to replace the current configuration.


apic1# show snapshot files               
File    : ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
Created : 2015-11-21T01:00:21.167+00:00
Root    : 
Size    : 22926

apic1# configure
apic1(config)# snapshot import myImportPolicy 
apic1(config-import)# file ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
apic1(config-import)# action replace
apic1(config-import)# mode atomic
apic1(config-import)# end
apic1# trigger snapshot import myImportPolicy

Rollback Configuration Using Snapshots

The rollback feature provides an "undo" function that reverts changes made between one snapshot archive and a later snapshot archive. Only locally stored snapshot files are supported for rollback. You can optionally enable the preview mode to generate and view a rollback before implementing it.

Procedure

  Command or Action Purpose
Step 1

configure

Example:

apic1# configure

Enters global configuration mode.

Step 2

[no] snapshot rollback policy-name

Example:

apic1(config)# snapshot rollback myRollbackPolicy 

Creates a policy for rollback using snapshots.

Step 3

first-file filename

Example:

apic1(config-rollback)# first-file ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz

Specifies the name of the earlier file.

Step 4

second-file filename

Example:

apic1(config-rollback)# second-file ce2_DailyAutoBackup-2015-11-21T09-00-21.tar.gz

Specifies the name of the later file.

Step 5

[no] preview

Example:

apic1(config-rollback)# preview

(Optional) Specifies that the rollback changes are generated and previewed but not applied. When preview mode is enabled, no changes to the configuration are made. After previewing rollback changes, use the no preview command to exit preview mode and enable the rollback to be applied when you reenter the trigger snapshot rollback commands.

Step 6

end

Example:

apic1(config-rollback)# end

Returns to EXEC mode.

Step 7

trigger snapshot rollback policy-name

Example:

apic1# trigger snapshot rollback myRollbackPolicy

Executes the snapshot rollback task.

Examples

This example shows how to configure and execute a rollback without previewing it first.


apic1# show snapshot files               
File    : ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
Created : 2015-11-21T01:00:21.167+00:00
Root    : 
Size    : 22926

File    : ce2_DailyAutoBackup-2015-11-21T09-00-21.tar.gz
Created : 2015-11-21T09:00:24.025+00:00
Root    : 
Size    : 23588

apic1# configure
apic1(config)# snapshot rollback myRollbackPolicy 
apic1(config-rollback)# first-file ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
apic1(config-rollback)# second-file ce2_DailyAutoBackup-2015-11-21T09-00-21.tar.gz

apic1(config-rollback)# end
apic1# trigger snapshot rollback myRollbackPolicy

Uploading or Downloading a Snapshot File to a Remote Path

You can upload snapshot archive files from local storage to a remote path. You can also download snapshot archive files from the remote path.

Before you begin

You must configure a remote path to receive the file. See Configuring a Remote Path for File Export.

Procedure

  Command or Action Purpose
Step 1

configure

Example:

apic1# configure

Enters global configuration mode.

Step 2

[no] snapshot {upload | download} policy-name remote-path-name

Example:

apic1(config)# snapshot upload myUpPolicy 

Creates a policy for uploading or downloading snapshot files with a remote path.

Step 3

remote path remote-path-name

Example:

apic1(config-upload)# remote path myBackupServer

Specifies the name of a configured remote path to which the snapshot file will be sent.

Step 4

file filename

Example:

apic1(config-upload)# file ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz

Specifies the name of the snapshot file to be sent.

Step 5

end

Example:

apic1(config-upload)# end

Returns to EXEC mode.

Step 6

trigger snapshot {upload | download} policy-name

Example:

apic1# trigger snapshot upload myUpPolicy

Executes the snapshot upload or download task.

Examples

This example shows how to configure and execute the uploading of a snapshot file to a remote path.


apic1# show snapshot files               
File    : ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
Created : 2015-11-21T01:00:21.167+00:00
Root    : 
Size    : 22926

apic1# configure
apic1(config)# snapshot upload myUpPolicy 
apic1(config-upload)# remote path myBackupServer
apic1(config-upload)# file ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
apic1(config-upload)# end
apic1# trigger snapshot upload myUpPolicy

Managing Snapshot Files and Jobs

The following commands are available for managing snapshot files and jobs.

Command

Description

clear snapshot file filename

Removes a snapshot file from the local storage.

clear snapshot job job-name

Removes a snapshot job from the history.

show snapshot files

Displays the snapshot files in local storage.

show snapshot jobs

Displays recent snapshot tasks.

show snapshot active jobs

Displays currently-active snapshot tasks.

Examples

This example shows how to display snapshot files and the snapshot job history.


apic1# show snapshot files               
File    : ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz
Created : 2015-11-21T01:00:21.167+00:00
Root    : 
Size    : 22926

File    : ce2_DailyAutoBackup-2015-11-21T09-00-21.tar.gz
Created : 2015-11-21T09:00:24.025+00:00
Root    : 
Size    : 23588

apic1# show snapshot jobs                         
Type      : export
Run       : 2015-11-21T01-00-17
State     : success
Details   : Success
File Name : ce2_DailyAutoBackup-2015-11-21T01-00-17.tar.gz

Type      : export
Run       : 2015-11-21T09-00-21
State     : success
Details   : Success
File Name : ce2_DailyAutoBackup-2015-11-21T09-00-21.tar.gz

Type      : rollback
Run       : 2015-11-22T00-25-06
State     : running
Details   : 
File Name : not applicable

apic1# clear snapshot job 2015-11-22T00-25-06