To automatically backup the configuration of a Cisco switch, you can use the “copy running-config startup-config” command. This command will save the current configuration (running config) to the startup configuration, which is loaded every time the switch is rebooted.
You can also schedule regular backups to be taken at specific intervals using the “archive” feature. This feature allows you to specify when backups are taken, how many backups are kept, and where the backups are stored (e.g. on a remote server via FTP or TFTP).
Here is an example of how to configure the archive feature to take a backup every day at midnight and keep the last 7 backups:
archive path ftp://username:firstname.lastname@example.org/backups/switch1 time-period 1440 write-memory
This will use FTP protocol to connect to the ftp server, upload the configs to the ‘switch1’ folder in the ‘backup’ folder. It will take backup every 1440 minutes(24 hours).
Please keep in mind, the above commands will work on Cisco IOS and IOS-XE platforms but the commands may vary slightly on other platforms.