This script will backup specific [NVRAM](http://en.wikipedia.org/wiki/Non-volatile_random-access_memory “NVRAM”) variables and its values, and generates a script that can be used later to restore configurations. It is helpful after an upgrade or in the event of problems.
-
Router (MIPSEL) flashed with Tomato Firmware
-
Basic Linux knowledge
-
A network mounted filesystem
-
Tested on AC-66U running latest Shibby build
- Download the nvram-backup script to your desired backup directory (i.e. CIFS, USB, or NFS). I usually mount a CIFS1 or USB where I keep all backup data, logs, and scripts.
- Login to your router
- Click on Administration then Scripts
- Paste the following in the Init tab and click to save
REMOTE_PATH=<ADD FULL REMOTE PATH WHERE SCRIPT RESIDES>
LOCAL_PATH=/tmp/nvrambackup
if [ ! -s "$REMOTE_PATH" ]
then
sleep 5
mkdir $LOCAL_PATH
cp $REMOTE_PATH/nvram-backup.sh $LOCAL_PATH/nvram-backup.sh
cp $REMOTE_PATH/nvram-backup.cfg $LOCAL_PATH/nvram-backup.cfg
chmod a+x $LOCAL_PATH/nvram-backup.sh
fi
- Choose the variables you would like to backup and place it on a file called nvram-backup.cfg. You can get a list of all variables and values currently available by ssh’ing to your router and execute the following command:
nvram show
- Run and verify:
sh /tmp/nvrambackup/nvram-backup.sh
- Add cronjob to run at 12:00AM on the first of every month:
cru a backup-nvram "0 0 1 * * /tmp/nvrambackup/nvram-backup.sh"
To restore, run the restore file generated by the main script then reboot the router.
Note: Use at your own risk. Be careful and thoughtful not to brick your router.