|
Router Configuration Backup Utility (copy_to_tftp) |
Top Previous Next |
|
This script backs up the router configuration files to a TFTP server. It cycles through a list of routers performing a “copy running-config tftp:”.
Program Name: copy_to_tftp
The configuration filename that is saved to the TFTP server is <routername-confg>. This is the default file name that the router chooses. There is also an option to have the configuration filename be the name/ip_address that is specified in the router file (i.e. –rf <filename>). This is done using the –urfn option. For example, if one of the lines in the router file is 10.10.1.1, then the config file name would be 10.10.1.1-confg. The directory that the configuration files are saved to, can also be changed using the “-subdir” option. By default the script will attempt to save the configuration file to the root TFTP directory. By using the –subdir option, you can have multiple configuration files for the same router saved under different directories. Multiple levels below the root tftp directory can be specified (See the 2nd example below)
Also when using a UNIX TFTP server, the file name for the router configuration files must be created before the script runs. This is typical behavior for UNIX TFTP servers. By using the –tftproot option the script will create (i.e. UNIX touch command) the configuration files on the TFTP server for you so you don’t have to do it manually. Using the –subdir and –tftproot options together enables the script to create a new directory, under the tftp root directory, and “touch” the config files in that directory. When using the –tftproot option, the TFTP server ip address must be the same as the system that the script is being run from. (Note, A TFTP sub-directory created by the script (-subdir) will create the directory with the permissions of “read-write-execute” for “user-group-other” respectively [or 777]. Router configuration files that are touched by the script, will be created with “read-write” permissions for “user-group-other” respectively [or 666]).
For TFTP Server applications on Microsoft Windows Platforms, the filename usually does not need to pre-exist on the TFTP Server before the router attempts to write its configuration file to the TFTP Server.
Sample Command: The following command will backup the configuration files for the routers listed in the file rtrs.rt. The files will be backed up to the 10.10.1.20 TFTP Server. The configs will be stored in a sub-directory under the root TFTP directory named 02-25-03_configs. The config files will automatically be touched on the TFTP server. The –tftproot option also causes the script to automatically create the directory specified in the –subdir option. The script WILL prompt the user for passwords because the -pw option is not being used.
copy_to_tftp –rf rtrs.rt –ipaddr 10.10.1.20 –subdir 02-25-03_configs –tftproot /tftpboot
Sample Command: This example emphasizes that the script can create multilevel directories under the root tftp directory. The following command will backup the configuration files for the routers listed in the file rtrs.rt. The files will be backed up to the 10.10.1.20 TFTP Server. The configs will be stored in a sub-directory under the root TFTP directory named abc/02-25-03_configs. The config files will automatically be touched on the TFTP server. The –tftproot option also causes the script to automatically create both directories specified in the –subdir option. The script WILL prompt the user for passwords because the -pw option is not being used.
copy_to_tftp –rf rtrs.rt –ipaddr 10.10.1.20 –subdir abc/02-25-03_configs –tftproot /tftpboot
Sample Command: This example shows the use of the autodir option. The following command will backup the configuration files for the routers listed in the file rtrs.rt. The files will be backed up to the 10.10.1.20 TFTP Server. Assuming the date is August 5th 2010, the configs will be stored in /tftpboot/rtr_configs/08052010. Note, the rtr_configs directory does not have to exist before the script is run. The script will not prompt the user for passwords or a password encryption key because the -pw option is used with an unencrypted password file. The -ulog opition will automatically create a unique detailed trace log file.
copy_to_tftp -ulog -pw logins.txt –rf rtrs.rt –ipaddr 10.10.1.20 –tftproot /tftpboot –subdir rtr_configs -autodir date
Sample Command: Same example as above but password file is encrypted. Here, the user will not be prompted for a password encryption key because the -nokey option is specified. This command line is a good example of all that would be need to put into a Unix/Linux shell file or a windows batch file. The shell file or batch file could then easily be called to run through cron or windows scheduler.
copy_to_tftp -ulog -nokey -pw logins_encr.txt –rf rtrs.rt –ipaddr 10.10.1.20 –tftproot /tftpboot –subdir rtr_configs -autodir date |