- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
05-Configuration file management commands | 128.21 KB |
Configuration file management commands
archive configuration interval
archive configuration location
Configuration file management commands
archive configuration
Use archive configuration to manually archive the running configuration to the configuration archive directory.
Syntax
archive configuration
Views
User view
Default command level
3: Manage level
Usage guidelines
Before manually archiving the running configuration, complete the following tasks:
1. Create a directory for saving configuration archives.
2. Use the archive configuration location command to specify the directory as the configuration archive directory and specify an archive name prefix.
Configuration archive is a function that facilitates configuration rollback. It provides manual and automatic methods for saving the running configuration as checkpoint references. For more information about the archiving mechanism, see the section about configuration rollback in Fundamentals Configuration Guide.
To ensure system performance, follow these guidelines:
· If the device configuration does not change frequently, manually archive the running configuration as needed.
· If the device configuration changes frequently, archive the running configuration manually, or configure automatic archiving with an interval longer than 1440 minutes (24 hours).
Examples
# Archive the running configuration.
<Sysname> archive configuration
Warning: Save the running configuration to an archive file. Continue? [Y/N]: Y
Please wait...
Info: The archive configuration file myarchive_1.cfg is saved.
Related commands
archive configuration location
archive configuration interval
Use archive configuration interval to enable automatic running-configuration archiving and set the archiving interval.
Use undo archive configuration interval to restore the default.
Syntax
archive configuration interval minutes
undo archive configuration interval
Default
The system does not automatically archive the running configuration.
Views
System view
Default command level
3: Manage level
Parameters
minutes: Specifies the interval (in minutes) for automatically saving the running configuration. The value range is 10 to 525600 (365 days).
Usage guidelines
Before enabling automatic configuration archiving, complete the following tasks:
1. Create a directory for saving configuration archives.
2. Use the archive configuration location command to specify the directory as the configuration archive directory and specify an archive name prefix.
Configuration archive is a function that facilitates configuration rollback. It provides manual and automatic methods for saving the running configuration as checkpoint references.
Automatic configuration archiving enables the system to automatically save the running configuration to the archive directory. For more information about the archiving mechanism, see the section about configuration rollback in Fundamentals Configuration Guide.
To ensure system performance, follow these guidelines:
· If the device configuration does not change frequently, manually archive the running configuration as needed.
· If the device configuration changes frequently, archive the running configuration manually, or configure automatic archiving with an interval longer than 1440 minutes (24 hours).
· Change the archiving interval depending on the available amount of storage space. The shorter the interval, the more free storage space is required.
Examples
# Configure the system to archive the running configuration every 1600 minutes.
<Sysname> system-view
[Sysname] archive configuration interval 1600
Info: Archive files will be saved every 1600 minutes.
Related commands
archive configuration location
archive configuration location
Use archive configuration location to configure the directory and file name prefix for archiving the running configuration.
Use undo archive configuration location to restore the default.
Syntax
archive configuration location directory filename-prefix filename-prefix
undo archive configuration location
Default
No configuration archive directory or configuration archive file name prefix has been set.
Views
System view
Default command level
3: Manage level
Parameters
directory: Specifies a configuration archive directory, a case-insensitive string of 1 to 63 characters. The directory must take the format storage-medium-name:/folder-name. This directory must already exist on the device.
filename-prefix: Specifies a file name prefix for configuration archives, a case-insensitive string of 1 to 30 characters. Valid characters are letters, digits, underscores (_), and hyphens (-).
Usage guidelines
Before archiving the running configuration, either manually or automatically, you must configure a directory and file name prefix for configuration archives.
Configuration archives take the file name format prefix_serial number.cfg, for example, 20080620archive_1.cfg and 20080620archive_2.cfg. The serial number is automatically assigned from 1 to 1000, increasing by 1. After the serial number reaches 1000, it restarts from 1.
After you change the file directory or file name prefix, or reboot the device, the old configuration archives are regarded as common configuration files, the configuration archive counter resets, and the display archive configuration command does not display them. The serial number for new configuration archives starts from 1.
The undo archive configuration location command not only removes the configuration archive directory and file name prefix settings, but also disables the configuration archive function (both manual and automatic methods), restores the default settings of the archive configuration interval and archive configuration max commands, and clears all configuration archives.
Examples
# Configure the configuration archive directory as flash:/archive/ and the archive file name prefix as my_archive:
1. Create the directory flash:/archive.
<Sysname> mkdir archive
.
%Created dir flash:/archive.
2. Specify the directory as the configuration archive directory, and configure an archive file name prefix.
<Sysname> system-view
[Sysname] archive configuration location flash:/archive filename-prefix my_archive
mkdir
archive configuration max
Use archive configuration max to set the maximum number of running-configuration archives.
Use undo archive configuration max to restore the default.
Syntax
archive configuration max file-number
undo archive configuration max
Default
A maximum of five configuration archives can be saved.
Views
System view
Default command level
3: Manage level
Parameters
file-number: Sets the maximum number of configuration archives that can be saved. The value range is 1 to 10. Change the setting depending on the available storage space.
Usage guidelines
Before you can set a limit on configuration archives, use the archive configuration location command to specify a configuration archive directory and archive file name prefix.
After the maximum number of configuration archives is reached, the system deletes the oldest archive for the new archive.
Changing the limit setting to a lower value does not cause immediate deletion of exceeding archives. Instead, the configuration archive function deletes the oldest n files when a new archive is manually or automatically saved, where n = current archive count – new archive limit + 1.
Suppose seven configuration archives have been saved before the archive limit is set to four. When saving a new configuration archive, the system first deletes the oldest four (7 – 4 + 1) archives.
If you execute the undo archive configuration location command, the default archive limit is restored.
Examples
# Set the maximum number of configuration archives to 10.
<Sysname> system-view
[Sysname] archive configuration max 10
Related commands
archive configuration location
backup startup-configuration
Use backup startup-configuration to back up the next-startup configuration file to a TFTP server.
Syntax
backup startup-configuration to dest-addr [ dest-filename ]
Views
User view
Default command level
2: System level
Parameters
dest-addr: Specifies a TFTP server's IPv4 address or name, a sting of 1 to 20 characters.
dest-filename: Specifies the target file name used for saving the file on the server. The file name must have the extension .cfg. If you do not specify a target file name, the source file name is used.
Usage guidelines
Before performing this task, make sure the server is reachable, the server is enabled with TFTP service, and you have read and write permissions.
This command backs up only the main next-startup configuration file.
Examples
# Back up the next-startup configuration file to the TFTP server at 2.2.2.2, and set the target file name to 192-168-1-26.cfg.
<Sysname> display startup
MainBoard:
Current startup saved-configuration file: flash:/config.cfg
Next main startup saved-configuration file: flash:/config.cfg
Next backup startup saved-configuration file: flash:/startup.cfg
<Sysname> backup startup-configuration to 2.2.2.2 192-168-1-26.cfg
Backup next startup-configuration file to 2.2.2.2, please wait…finished!
configuration replace file
Use configuration replace file to roll back configuration.
Syntax
configuration replace file filename
Views
System view
Default command level
3: Manage level
Parameters
filename: Specifies the name of the replacement configuration file for configuration rollback.
Usage guidelines
To replace the running configuration with the configuration in a configuration file without rebooting the device, use the configuration rollback function. This function helps you revert to a previous configuration state or adapt the running configuration to different network environments.
To ensure a successful rollback:
· Make sure the replacement configuration file is created by using the configuration archive function or the save command on the current device.
· If the configuration file is not created on the current device, make sure the configuration file content format is fully compatible with the current device.
· The replacement configuration file is not encrypted.
Examples
# Replace the running configuration with the configuration in the my_archive_1.cfg configuration file.
<Sysname> system-view
[Sysname] configuration replace file my_archive_1.cfg
Current configuration will be lost, save current configuration? [Y/N]:n
Info: Now replacing the current configuration. Please wait...
Info: Succeeded in replacing current configuration with the file my_archive_1.cfg.
display archive configuration
Use display archive configuration to display configuration archive information, including the archive directory, archive prefix, archive interval, maximum number of archives, and saved archives.
Syntax
display archive configuration [ | { begin | exclude | include } regular-expression ]
Views
Any view
Default command level
1: Monitor level
Parameters
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Examples
# Display configuration archive information.
<Sysname> display archive configuration
Location: flash:/archive
Filename prefix: my_archive
Archive interval in minutes: 120
Maximum number of archive files: 10
Saved archive files:
No. TimeStamp FileName
1 Jan 05 2013 20:24:54 my_archive_1.cfg
2 Jan 05 2013 20:34:54 my_archive_2.cfg
# 3 Jan 05 2013 20:44:54 my_archive_3.cfg
'#' indicates the most recent archive file.
Next archive file to be saved: my_archive_4.cfg
Table 1 Command output
Field |
Description |
Location |
Directory for saving running-configuration archives. |
Filename prefix |
File name prefix for configuration archives. |
Archive interval in minutes |
Interval (in minutes) for the system to automatically archive the running configuration. If automatic configuration saving is disabled, this field is not available. |
TimeStamp |
Time when the configuration archive was created. |
Filename |
Configuration archive file name, with the directory excluded. |
display current-configuration
Use display current-configuration to display the running configuration.
Syntax
display current-configuration [ configuration [ configuration ] | interface [ interface-type [ interface-number ] ] | exclude modules ] [ by-linenum ] [ | { begin | exclude | include } regular-expression ]
Views
Any view
Default command level
2: System level
Parameters
configuration [ configuration ]: Displays feature configuration. The configuration argument specifies a feature module. If no feature module is specified, this command displays all feature settings you have made. Available feature modules depend on your configuration.
interface [ interface-type [ interface-number ] ]: Displays interface configuration, where interface-type represents the interface type and interface-number represents the interface number.
exclude modules: Excludes the configuration of specific modules. The modules argument can only be acl, which specifies the IPv4 ACL configuration.
by-linenum: Displays the number of each line.
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Usage guidelines
Use this command to verify the configuration you have made.
Typically, this command does not display parameters that are set to their default settings.
If the system has automatically changed the setting you have made for a parameter, for example, due to a system restriction, this command displays the effective setting rather than the configured one. For example, assign IP address 11.11.11.11 24 to a Loopback interface. However, the display current-configuration command displays 11.11.11.11 255.255.255.255, because the subnet mask for a Loopback interface must be 32 bits, and the system has automatically corrected the subnet mask.
Examples
# Display the configuration from the line containing "user-interface" to the last line in the running configuration.
<Sysname> display current-configuration | begin user-interface
user-interface aux 0
user-interface vty 0 15
authentication-mode none
user privilege level 3
#
return
# Display the running SNMP configuration.
<Sysname> display current-configuration | include snmp
snmp-agent
snmp-agent local-engineid 800063A203000FE240A1A6
snmp-agent community read public
snmp-agent community write private
snmp-agent sys-info version all
· display saved-configuration
· reset saved-configuration
· save
display default-configuration
Use display default-configuration to display the factory defaults.
Syntax
display default-configuration [ | { begin | exclude | include } regular-expression ]
Views
Any view
Default command level
2: System level
Parameters
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Usage guidelines
The device is shipped with some basic settings called "factory defaults." These default settings make sure the device can start up and run correctly when it has no configuration file or the configuration file is corrupted.
Factory defaults vary with device models and might differ from the default settings of commands.
Examples
# Display the factory defaults.
<Sysname> display default-configuration
#
domain default enable system
#
telnet server enable
#
undo ip redirects
undo ip ttl-expires
undo ip unreachables
#
vlan 1
#
radius scheme system
server-type extended
primary authentication 127.0.0.1 1645
primary accounting 127.0.0.1 1646
user-name-format without-domain
#
domain system
access-limit disable
state active
idle-cut disable
---- More ----
Related commands
· display current-configuration
· display saved-configuration
display saved-configuration
Use display saved-configuration to display the contents of the configuration file to be used at the next startup.
Syntax
display saved-configuration [ by-linenum ] [ | { begin | exclude | include } regular-expression ]
Views
Any view
Default command level
2: System level
Parameters
by-linenum: Identifies each line of displayed information with a line number.
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Usage guidelines
Use this command to verify that important settings have been saved to the next-startup configuration file.
For a device supporting main and backup configuration files, this command displays the main next-startup configuration file.
If no next-startup configuration file has been specified, or the specified next-startup configuration does not exist, this command displays the error message "The config file does not exist!"
Examples
# Display the next-startup configuration file.
<H3C> display saved-configuration
#
version 5.20, Alpha 2607P01
#
sysname WX5540E_LSW
#
domain default enable system
#
ipv6 prefer temporary-address
#
telnet server enable
#
vlan 1
#
vlan 100
arp-snooping enable
#
radius scheme system
server-type extended
primary authentication 127.0.0.1 1645
primary accounting 127.0.0.1 1646
user-name-format without-domain
#
domain system
---- More ----
At the prompt of More, press Enter to display the next line, press Space to display the next screen of configuration, or press Ctrl+C or any other key to stop displaying the configuration.
# Display the next-startup configuration file, and number each line.
<H3C> display saved-configuration by-linenum
1: #
2: version 5.20, Alpha 2607P01
3: #
4: sysname WX5540E_LSW
5: #
6: domain default enable system
7: #
8: ipv6 prefer temporary-address
9: #
10: telnet server enable
11: #
12: vlan 1
13: #
14: vlan 100
15: arp-snooping enable
16: #
17: radius scheme system
18: server-type extended
19: primary authentication 127.0.0.1 1645
20: primary accounting 127.0.0.1 1646
21: user-name-format without-domain
22: #
23: domain system
---- More ----
· display current-configuration
· reset saved-configuration
· save
display startup
Use display startup to display the current startup configuration file, the next-startup configuration file.
Syntax
display startup [ | { begin | exclude | include } regular-expression ]
Views
Any view
Default command level
1: Monitor level
Parameters
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Usage guidelines
Current startup configuration file is the configuration file used at this startup. Next-startup configuration file is the configuration file used at the next startup.
Examples
# Display the startup configuration files.
<Sysname> display startup
MainBoard:
Current startup saved-configuration file: flash:/startup.cfg
Next main startup saved-configuration file: flash:/startup.cfg
Next backup startup saved-configuration file: NULL
Table 2 Command output
Field |
Description |
MainBoard |
Displays the startup configuration files on the device. |
Current startup saved-configuration file |
Configuration file to be used at the current startup. |
Next main startup saved-configuration file |
Main configuration file to be used at the next startup. |
Next backup startup saved-configuration file |
Backup configuration file to be used at the next startup. |
(This file does not exist.) |
If the specified next-startup configuration file has been deleted, this comment appears next to the file name. |
startup saved-configuration
display this
Use display this to display the running configuration in the current view.
Syntax
display this [ by-linenum ] [ | { begin | exclude | include } regular-expression ]
Views
Any view
Default command level
1: Monitor level
Parameters
by-linenum: Displays the number of each line.
|: Filters command output by specifying a regular expression. For more information about regular expressions, see Fundamentals Configuration Guide.
begin: Displays the first line that matches the specified regular expression and all lines that follow.
exclude: Displays all lines that do not match the specified regular expression.
include: Displays all lines that match the specified regular expression.
regular-expression: Specifies a regular expression, a case-sensitive string of 1 to 256 characters.
Usage guidelines
Use this command to verify the configuration you have made in a certain view.
Typically, this command does not display parameters that are set to their default settings.
For some parameters that can be successfully configured even if their dependent features are not enabled, this command displays their settings after the dependent features are enabled.
Executed in any user interface view, this command displays the running configuration of all user view interfaces.
Executed in any VLAN view, this command displays the running configuration of all VLANs.
Examples
# Display the running configuration on interface GigabitEthernet 1/0/1.
<Sysname> system-view
[Sysname] interface GigabitEthernet 1/0/1
[Sysname-GigabitEthernet1/0/1] display this
#
interface GigabitEthernet1/0/1
port link-mode bridge
port link-type hybrid
undo port hybrid vlan 1
port hybrid vlan 2 to 4 untagged
port hybrid pvid vlan 2
#
return
# Display the running configuration on user interfaces.
<Sysname> system-view
[Sysname] user-interface vty 0
[Sysname-ui-vty0] display this
#
user-interface vty 0 15
user privilege level 3
user-interface vty 1 15
#
return
reset saved-configuration
Use reset saved-configuration to delete next-startup configuration files.
Syntax
reset saved-configuration [ backup | main ]
Views
User view
Default command level
3: Manage level
Parameters
backup: Deletes the backup next-startup configuration file.
main: Deletes the main next-startup configuration file.
Usage guidelines
|
CAUTION: Use this command with caution. This command permanently deletes the next-startup configuration files from the device. |
Delete the next-startup configuration file if it is corrupt or does not match the software version.
You can delete the main, the backup, or both. If the device has only one next-startup configuration file, the system sets the attribute of the configuration file to NULL instead of deleting the file.
If no configuration file attribute is specified, the reset saved-configuration command deletes the main startup configuration file.
Examples
# Delete the next-startup configuration file.
<Sysname> reset saved-configuration backup
The saved configuration file will be erased. Are you sure? [Y/N]:y
Configuration file in flash is being cleared.
Please wait ...
..
MainBoard:
Configuration file is cleared.
· display saved-configuration
· save
restore startup-configuration
Use restore startup-configuration to download a configuration file from a TFTP server and specify it as the next-startup configuration file.
Syntax
restore startup-configuration from src-addr src-filename
Views
User view
Default command level
3: Manage level
Parameters
src-addr: Specifies a TFTP server's IPv4 address or name. The name can comprise 1 to 20 characters.
src-filename: Specifies the file name of the configuration file to be downloaded.
Usage guidelines
Before restoring the configuration file for the next startup, make sure the server is reachable, the server is enabled with TFTP service, and you have read and write permissions.
This command restores only the main next-startup configuration file.
This command provides an easy method for configuration file restoration by automatically performing all operations required for restoring the next-startup configuration file.
It downloads the configuration file to the root directory of the storage medium and specifies the file as the next-startup configuration file.
Examples
# Download the configuration file config.cfg from the TFTP server at 2.2.2.2, and specify the file as the main next-startup configuration file.
<Sysname> restore startup-configuration from 2.2.2.2 config.cfg
Restore next startup-configuration file from 2.2.2.2. Please wait...finished!
save
Use save file-url to save the running configuration to a configuration file, without specifying the file as a next startup configuration file.
Use save [ safely ] [ backup | main ] [ force ] to save the running configuration to the root directory of the storage medium, and specify the file as a next startup configuration file.
Syntax
save file-url
save [ safely ] [ backup | main ] [ force ]
Views
Any view
Default command level
2: System level
Parameters
file-url: Specifies a file path, where the file extension must be .cfg.
safely: Saves the configuration file in safe mode. If this keyword is not specified, the system saves the configuration file in fast mode. Safe mode is less fast than fast mode, but more secure. In safe mode, the system saves configuration in a temporary file and starts overwriting the target next-startup configuration file after the save operation is complete. If a reboot or power failure occurs during the save operation, the next-startup configuration file is still retained. In fast mode, the device directly overwrites the target next-startup configuration file. If a reboot or power failure occurs during this process, the next-startup configuration file is lost.
backup: Saves the running configuration to a configuration file, and specifies the file as the backup next-startup configuration file.
main: Saves the running configuration to a configuration file, and specifies the file as the main next-startup configuration file.
force: Saves the running configuration to the next-startup configuration file already specified in the system. Without this keyword, the system asks you to confirm your operation. If you do not confirm your operation within 30 seconds, the system automatically aborts the operation. If you enter Y within the time limit, you can continue the save process and change the next-startup configuration file during this process.
Usage guidelines
If the file specified for file-url does not exist, the system creates the file before saving the configuration.
If the backup or main keyword is not specified, the main keyword applies.
Examples
# Save the running configuration to the configuration file startup.cfg in the root directory of the storage medium, and specify the file as the next-startup configuration file:
1. Display the main next-startup configuration file on the device.
<Sysname> display startup
MainBoard:
Current startup saved-configuration file: NULL
Next main startup saved-configuration file: flash:/aa.cfg
Next backup startup saved-configuration file: NULL
// The output shows that the main next-startup configuration file on the device is aa.cfg.
2. Save the running configuration to the main next-startup configuration file on the device and specify the filename as startup.cfg.
<Sysname> save
The current configuration will be written to the device. Are you sure? [Y/N]:y
Please input the file name(*.cfg)[flash:/aa.cfg]
(To leave the existing filename unchanged, press the enter key):startup.cfg
flash:/startup.cfg exists, overwrite? [Y/N]:y
Validating file. Please wait.................
Saved the current configuration to mainboard device successfully.
3. Display the main next-startup configuration file on the device.
<Sysname> display startup
MainBoard:
Current startup saved-configuration file: NULL
Next main startup saved-configuration file: flash:/startup.cfg
Next backup startup saved-configuration file: NULL
// The output shows that the main next-startup configuration file has changed from aa.cfg to startup.cfg on the device.
· display current-configuration
· display saved-configuration
· reset saved-configuration
startup saved-configuration
Use startup saved-configuration to specify the configuration file to be used at the next startup.
Use undo startup saved-configuration to configure the device to start up with the factory defaults at the next startup.
Syntax
startup saved-configuration cfgfile [ backup | main ]
undo startup saved-configuration
Views
User view
Default command level
3: Manage level
Parameters
cfgfile: Specifies a configuration file name with the extension .cfg. The file must be stored in the root directory of the storage medium.
backup: Sets the configuration file as the backup next-startup configuration file.
main: Sets the configuration file as the main next-startup configuration file.
Usage guidelines
If neither backup nor main is specified, the startup saved-configuration command specifies the main next-startup configuration file.
For high availability, specify separate files as the main and backup next-startup configuration files, even though they can be the same file.
The undo startup saved-configuration command only changes the file attribute of the main and backup next-startup configuration files to NULL. It does not delete the two configuration files.
You can also specify a configuration file as the startup configuration file to be used at the next startup when you use the save command save the running configuration to it.
Examples
# Specify a next-startup configuration file.
<Sysname> startup saved-configuration testcfg.cfg
Please wait ...
Setting the master board ..........
... Done!
Related commands
display startup