OpenWrt: Archive router configs for backup

You should always have a backup of the main configuration settings of your OpenWrt device.  A single change via LuCI or from the console can leave you with questions on what changed and how to get back to your original working condition.

In this article, I’ll show you how to archive your main configuration settings, and then transfer them via scp to a desktop for safe keeping.

Backup

Start by ssh’ing to the OpenWrt router using the command below or an ssh client like PuTTy on Windows.

ssh root@<openwrt>

Once logged into OpenWrt, create an archive in the /tmp folder of everything in the /etc directory:

tar cvf /tmp/openwrt-etc.tar /etc/*

Transfer

The next step is to take the archive on the OpenWrt router at “/tmp/openwrt-etc.tar”, and copy this back to your desktop machine.

If you run a *nix desktop running an openssh-server, then while still logged into the router you can use scp to push it back to your home directory using the command below.

scp /tmp/openwrt-etc.tar <user>@<desktop>:/home/<user>/.

If you are running a Windows desktop or don’t have your *nix desktop running an ssh server then you can use scp to pull it off the OpenWrt server.  For Windows PuTTy pscp, that command looks like:

pscp -scp root@<openwrt>:/tmp/openwrt-etc.tar .

Notice that we forced scp with ‘-scp’ so that it does not fallback to using sftp.

 

 

NOTES

Ubuntu install openssh server

sudo apt-get install openssh-server