Backing up Linksys WRT610n

This entry will describe the steps that I followed to back up my personal router.

If you read this link to make a backup from your current configuration perhaps you find the same issues as me:


First of all I decided to check what is mounted in my router:

root@OpenWrt:/# mount
 rootfs on / type rootfs (rw)
 /dev/root on /rom type squashfs (ro,relatime)
 proc on /proc type proc (rw,noatime)
 sysfs on /sys type sysfs (rw,noatime)
 tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
 /dev/mtdblock5 on /overlay type jffs2 (rw,noatime)
 overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
 tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=755)
 devpts on /dev/pts type devpts (rw,relatime,mode=600)
 debugfs on /sys/kernel/debug type debugfs (rw,noatime)

If you want to back up your ART Partition use:
# dd if=/dev/$(grep -i '"art"' /proc/mtd |cut -c 1-4) of=/tmp/art.backup

My advice should be that before run a piece of the previous command just to know which partitions will be backed up:
root@OpenWrt:/# grep -i '"art"' /proc/mtd |cut -c 1-4

Surprisingly there isn’t any out for previous command so nothing will be backed up, so I decided check /proc/mtd file and test the grep command with other params:

 root@OpenWrt:/proc# cat /proc/mtd
 dev: size erasesize name
 mtd0: 00040000 00010000 "boot"
 mtd1: 007b0000 00010000 "firmware"
 mtd2: 000008f0 000008f0 "loader"
 mtd3: 0012b2f4 00010000 "linux"
 mtd4: 00684400 00010000 "rootfs"
 mtd5: 00480000 00010000 "rootfs_data"
 mtd6: 00010000 00010000 "nvram"
 root@OpenWrt:/proc# grep -i "boot" /proc/mtd |cut -c 1-4
 root@OpenWrt:/proc# grep -i "rootfs" /proc/mtd |cut -c 1-4

Before starting to create backup files it’s needed to check if we have enough space in our device:

 root@OpenWrt:/tmp/log# df -h
 Filesystem Size Used Available Use% Mounted on
 rootfs 4.5M 276.0K 4.2M 6% /
 /dev/root 2.0M 2.0M 0 100% /rom
 tmpfs 29.9M 7.7M 22.2M 26% /tmp
 /dev/mtdblock5 4.5M 276.0K 4.2M 6% /overlay
 overlayfs:/overlay 4.5M 276.0K 4.2M 6% /
 tmpfs 512.0K 0 512.0K 0% /dev

Backing up fully the /proc/mtd content:

root@OpenWrt:~# dd if=/dev/mtd0 of=/tmp/boot.backup-`date +%F`
 512+0 records in
 512+0 records out

root@OpenWrt:/tmp/log# dd if=/dev/mtd1 of=/tmp/firmware.backup-`date +%F`
 15744+0 records in
 15744+0 records out

root@OpenWrt:/tmp/log# dd if=/dev/mtd2 of=/tmp/loader.backup-`date +%F`
4+1 records in
4+1 records out

root@OpenWrt:/tmp/log# dd if=/dev/mtd3 of=/tmp/linux.backup-`date +%F`
2393+1 records in
2393+1 records out

root@OpenWrt:/tmp/log# dd if=/dev/mtd4 of=/tmp/rootfs.backup-`date +%F`
13346+0 records in
13346+0 records out

root@OpenWrt:/tmp/log# dd if=/dev/mtd5 of=/tmp/rootfs_data.backup-`date +%F`
9216+0 records in
9216+0 records out

root@OpenWrt:/tmp/log# dd if=/dev/mtd6 of=/tmp/nvram.backup-`date +%F`
128+0 records in
128+0 records out

$ scp root@<ANOTHER_HOST>:/tmp/*backup-2015-03-29 .
 boot.backup-2015-03-29 100% 256KB 1.1MB/s 00:02
 firmware.backup-2015-03-29 100% 7872KB 1.1MB/s 00:07
 linux.backup-2015-03-29 100% 1197KB 1.2MB/s 00:01
 loader.backup-2015-03-29 100% 2288 2.2KB/s 00:00
 nvram.backup-2015-03-29 100% 64KB 64.0KB/s 00:00
 rootfs.backup-2015-03-29 100% 6673KB 1.3MB/s 00:05
 rootfs_data.backup-2015-03-29 100% 4608KB 1.1MB/s 00:04

Backup configurations:

root@OpenWrt:~# sysupgrade --create-backup /tmp/backup-`cat /proc/sys/kernel/hostname`-`date +%F`.tar.gz; ls /tmp/backup*
 Saving config files...

I also downloaded this file to my computer and review which files were compressed in tar.gz file:

$ tar tvzf backup-OpenWrt-2015-03-29.tar.gz
 -rw-r--r-- root/root 763 2015-03-29 13:51 etc/config/dhcp
 -rw-r--r-- root/root 134 2015-03-29 13:42 etc/config/dropbear
 -rw-r--r-- root/root 3887 2015-03-29 05:37 etc/config/firewall
 -rw-r--r-- root/root 786 2015-03-29 13:51 etc/config/network
 -rw-rw-r-- root/root 269 2015-02-25 08:12 etc/config/system
 -rw-r--r-- root/root 686 2015-03-29 13:51 etc/config/wireless
 -rw------- root/root 458 2015-03-29 13:52 etc/dropbear/dropbear_dss_host_key
 -rw------- root/root 805 2015-03-29 13:52 etc/dropbear/dropbear_rsa_host_key
 -rw-rw-r-- root/root 123 2015-02-25 08:12 etc/group
 -rw-rw-r-- root/root 20 2015-02-25 08:12 etc/hosts
 -rw-rw-r-- root/root 101 2015-02-25 08:12 etc/inittab
 -rw-rw-r-- root/root 190 2015-03-29 14:00 etc/passwd
 -rw-rw-r-- root/root 530 2015-02-25 08:12 etc/profile
 -rw-rw-r-- root/root 132 2015-02-25 08:12 etc/rc.local
 -rw------- root/root 153 2015-03-29 14:00 etc/shadow
 -rw-rw-r-- root/root 9 2015-02-25 08:12 etc/shells
 -rw-rw-r-- root/root 872 2015-03-26 18:02 etc/sysctl.conf

These are some useful references which I found during this process:

“Do your own thing on your own terms and get what you came here for.”
— Oliver James

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s