Making backups for the router configs



My router runs on OpenWRT and to backup its configuration I simply run the following shell script from my laptop to get the configuration archive in a local directory.

#!/bin/sh

ssh root@192.168.1.1 <<'ENDSCRIPT'
rm /root/backups/router-backup.tar.gz
sysupgrade -b /root/backups/router-backup.tar.gz
ENDSCRIPT
scp root@192.168.1.1:/root/backups/router-backup.tar.gz ~/router_backups/

sysupgrade is an OpenWrt tool for managing the system versions, which has an option for making backups in the form of tar.gz files. For making backups of any other remote system, this can be replaced by a script to produce an archive with the system configuration. A tar.gz file with contents of /etc is sufficient to backup such simple website as this one (given that all content is originally stored locally).