OpenWrt Forum Archive

Topic: openwrt full backup - problems mtd

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I have troubles to configure our openwrt backup, especially to understand why to save especially mtd-devs.
Usually I would save the /etc/config/ files, but I am adviced by the wiki (http://wiki.openwrt.org/doc/howto/generic.backup) to make some dd of the mtd-devs.
So my beginner questions are:

- What is an ART-partition? Is this the mtd where the bootloader is stored?
If I do
> grep '"art"' /proc/mtd | cut -c 1-4
I see the mtd4 is used as ART-partition, but shouldn`t it be mtd0 for locating the bootloader, should it?
- It is also adviced to do a dd of /dev/mtd0 for boot. So where is the difference between mtd4 and mtd0?

Help would be appreciated, thanks in advance.

mtd0 is bootloader,ART is another partition.they are two different things.
Definitely you'd better also backup you ART partition.

I will write a doc about i know latter.

Yes please write a doc. What is the ART-partition? And what is stored on this partition?

That depends totally by the device. E.g. in my WNDR3700 ART contains the MAC addresses etc., and is normally not touched by Openwrt at all.

There is no generic answer to your question. So far you have not even mentioned your device type.


Read http://wiki.openwrt.org/doc/techref/flash.layout for more elaborate discussion.

Hello hnyman, were are using several Linksys WRT54GL. Well, I don't think I got it. Why should I backup the mac addresses? When I have to do a recovery  I usually have to replace the Access Point. Is there a way to do a complete fullbackup?

GreenMap wrote:

Hello hnyman, were are using several Linksys WRT54GL. Well, I don't think I got it. Why should I backup the mac addresses? When I have to do a recovery  I usually have to replace the Access Point. Is there a way to do a complete fullbackup?

My point was that I have no need to backup ART partition, as Openwrt does not modify it, so it remains in original condition all the time.

I have a feeling that you are thinking a "full backup" with a too complicated way. Openwrt generally stores all configuration in its file system, so using file copy tools to create the backup of config files is usually enough. You can also use Luci GUI to make a bakcup of the settings.

I regularly reflash my router with a new firmware, and I usually have to restore only about 10 config files after the flash. No need for any "complete backup".

---

If you really want to make a "complete backup", then you could copy the contents of all the partitions somewhere, but then you need to figure also a way to restore them (as most of those mtd partitions are normally read-only).

1. # cat /proc/mtd

2. you should get something like this:

dev:    size   erasesize  name
mtd0: 00050000 00010000 "uboot"                                                         
mtd1: 00020000 00010000 "env"                                                           
mtd2: 00720000 00010000 "rootfs"                                                         
mtd3: 00010000 00010000 "config"                                                         
mtd4: 00010000 00010000 "config_bak"                                                     
mtd5: 00010000 00010000 "pot"                                                           
mtd6: 00010000 00010000 "traffic_meter"                                                 
mtd7: 00020000 00010000 "language"                                                       
mtd8: 00010000 00010000 "caldata"                                                       
mtd9: 0071ffc0 00010000 "mount_fs"
root@OpenWrt:~#

3. For each partition (mtd), extract it with the same name, using this logic:

cat /dev/mtd0 > /tmp/uboot.bin
cat /dev/mtd1 > /tmp/env.bin
cat /dev/mtd2 > /tmp/rootfs.bin
cat /dev/mtd3 > /tmp/config.bin
cat /dev/mtd4 > /tmp/config_bak.bin
cat /dev/mtd5 > /tmp/pot.bin
cat /dev/mtd6 > /tmp/traffic_meter.bin
cat /dev/mtd7 > /tmp/language.bin
cat /dev/mtd8 > /tmp/caldata.bin
cat /dev/mtd9 > /tmp/mount_fs.bin

4. Copy the binary dump files to a safe place.

Thank you hnyman. This was exactly what I have needed to configure our backup. You made my day.

After considering how to configure the backup integrating in our infrastructure we decided just to save the config files. Unfortunately we just can`t do a recursive scp on the /etc/-device regarding symlinks. So my plan is just to save /etc/config/ and the /root/ directory. (rsync isn't possible) Should this be enough or do we have to integrate some directories missing belonging in an essential backup?

You might use LuCI GUI to make a demo backup for you. Then you could analyze the generated backup tar.gz file to see which files the built-in backup logic selected for backup.

In general you only need the contents of /etc/config. However, it depends on your config installed modules: there might be /etc/firewall.user, configured public SSH keys in /etc/dropbear/authorized_keys, FTP config in /etc/vsftpd and so on.

Have you checked /overlay ?  In a "normal" setup you have read-only squashfs partition (from flash) and read-write jffs2 partition on top of that as "overlay", into which all modified files go. All you modified files are there in /overlay. E.g. modified files of /etc are in actually in /overlay/etc . Looking into that /overlay will tell you, which config files have been modified.

You might also run a script in the router to generate a tar archive of the whole /etc directory tree, and then backup that single file. As I need only a few files, I generate my backup with:

#!/bin/sh
cd /etc
tar -czv -f /tmp/HNsettings vsftpd.conf aiccu.conf config/radvd* config/network* config/firewall* config/luci_statistics* config/qos* config/wireless* config/dhcp* dropbear/authorized_keys

I must say I am deeply impressed how fast you respond to my openwrt requests. If I want to restore our OpenWRT, I will have to know which packages where installed on our routers.
Is a package-list automatically saved in the overlay or does I need to save the "opkg list-installed", also an overview of the installed packages seperately?

GreenMap wrote:

Is a package-list automatically saved in the overlay or does I need to save the "opkg list-installed", also an overview of the installed packages seperately?

I suggest you run opkg in the backup process and save the list. An alternative is to store /usr/lib/opkg/status (in overlay that is /overlay/usr/lib/opkg/status), but its format is rather verbose.

PS. I didn't know that file beforehand. I just spent 30 seconds looking into the /overlay and immediately noticed that file. I suggest you spend a few minutes looking into files on your router and try to figure out the contents.

I have finished my backupconfiguration yesterday. Thank you for your great support. How I said, I am really impressed about the support in this forum. Life long and prosper.

GreenMap wrote:

Yes please write a doc. What is the ART-partition? And what is stored on this partition?

If you are interested about the Atheros's ART,you can read the #2 in this topic:
https://forum.openwrt.org/viewtopic.php?id=35823

The discussion might have continued from here.