Skip to content

Instantly share code, notes, and snippets.

@rambotech
Created July 7, 2020 14:31
Show Gist options
  • Save rambotech/d1e2486228c5e972c3c9c8936920f2fc to your computer and use it in GitHub Desktop.
Save rambotech/d1e2486228c5e972c3c9c8936920f2fc to your computer and use it in GitHub Desktop.
Backup DD-WRT NVRAM settings to a shell script for easy restore.
# make a full restore shell script for the current nvram settings
FILE=$HOSTNAME-restore-sh
nvram show | grep = | grep -v -e =$ | awk -F'=' '{print $1}' | sort -f | (IFS=''; while read VAR; do VAL=$(nvram get ${VAR}); [ -n "$VAL" ] && printf 'nvram set %s='\''%s'\''\n' ${VAR} ${VAL/\'/\'\\\'\'}; done) > $FILE
nvram save >> $FILE
nvram commit >> $FILE
# insert an scp statement, etc, to copy the content to a storage location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment