User Tools

Site Tools


doc:howto:generic.backup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:generic.backup [2013/07/03 10:57]
lorema
doc:howto:generic.backup [2015/06/24 05:00] (current)
gftd [Backup your configuration]
Line 4: Line 4:
  
 ===== Create Backup ===== ===== Create Backup =====
-Once again, please have a look at the [[doc:​techref:​Flash Layout#Details]] and take notice, that the [[doc:​techref:​bootloader]] partition and ''​ART''/''​NVRAM''/​etc. and similar partition are NOT part of the OpenWrt firmware. So if something should go wrong and the data on these partition gets corrupted, you will not be able to replace it! You would have to go to the forum and ask somebody to make a backup of his, send it to you, you would have to replace the MAC address and then flash it via [[doc:​hardware:​port.JTAG]] since your device would probably not boot any longer.+Once again, please have a look at the [[doc:​techref:​flash.layout#Details]] and take notice, that the [[doc:​techref:​bootloader]] partition and ''​ART''/''​NVRAM''/​etc. and similar partition are NOT part of the OpenWrt firmware. So if something should go wrong and the data on these partition gets corrupted, you will not be able to replace it! You would have to go to the forum and ask somebody to make a backup of his, send it to you, you would have to replace the MAC address and then flash it via [[doc:​hardware:​port.JTAG]] since your device would probably not boot any longer.
  
 As already stated, these partition are not part of OpenWrt, and so we do not write to them, and thus it is very unlikely, that they get corrupted. But it is not impossible, and you should make a backup. As already stated, these partition are not part of OpenWrt, and so we do not write to them, and thus it is very unlikely, that they get corrupted. But it is not impossible, and you should make a backup.
Line 11: Line 11:
  
 <​code>​ <​code>​
-dd if=/​dev/​$(grep '"​art"'​ /proc/mtd |cut -c 1-4) of=/​tmp/​art.backup+dd if=/​dev/​$(grep ​-i '"​art"'​ /proc/mtd |cut -c 1-4) of=/​tmp/​art.backup
 </​code>​ </​code>​
  
Line 25: Line 25:
  
 Then copy your backup-file via scp or ssh to your PC and keep them safe for the time when you may need them. Then copy your backup-file via scp or ssh to your PC and keep them safe for the time when you may need them.
 +
 +===== Create Full MTD Backup =====
 +
 +This script was made for Netgear WNR2000v4 and may need to be tweaked for other routers. It assumes a working SSH. Also, it connects 3 times so it's [[doc:​techref:​signature.authentication|best to use an SSH key with this script]]. An improvement could be made by using rsync to have the remote files deleted after they are fetched in 1 command.
 +
 +To customize, try looking at /proc/mtd in your router to see how many mtd partitions this script should look for, or look in /dev (ls /dev/mtd*) to see how many partitions there are (note the highest number). Change the second number of the "​seq"​ command to match the highest /dev/mtd* partition number (eg. if highest is "/​dev/​mtd5",​ then change the "​seq"​ command to "seq 0 5").
 +
 +Also change the "​ROUTER"​ variable value to the hostname/IP of your OpenWRT router.
 +
 +On your local PC (not on the router), using a bash terminal (not Windows Command Prompt) create a new file (eg. ~/mtdbk.sh) containing the below script. Give this file execute privileges (chmod u+x mtdbk.sh) and then execute it (./​mtdbk.sh). This will backup your mtd contents to a zip file "​mtd_backup.zip"​ in the same folder as the script.
 +<​code>​
 +#!/bin/bash
 +BACKUP_DIR=mtd_backup
 +USER=root
 +ROUTER=extwnr
 +
 +mkdir -p $BACKUP_DIR
 +
 +ssh $USER@$ROUTER 'for i in `seq 0 6`; do
 +mtdname=`cat /proc/mtd | grep mtd$i | cut -d" " -f4 | sed s/​\"//​g`
 +echo "​Backing up ${mtdname}"​
 +dd if=/​dev/​mtd${i}ro of=/​tmp/​mtd${i}_${mtdname}.backup
 +done'
 +
 +scp $USER@$ROUTER:/​tmp/​mtd*.backup $BACKUP_DIR
 +
 +echo '​Removing remote backup files'
 +ssh $USER@$ROUTER 'rm /​tmp/​mtd*.backup'​
 +
 +printf '​\nZipping backup folder to mtd_backup.zip\n'​
 +zip -9mrv mtd_backup.zip mtd_backup
 +printf '​\n\nmtd backup complete.\nDont forget to unzip mtd_backup.zip before restoring.\nunzip -v mtd_backup.zip\n'​
 +</​code>​
 +==== Create Backup from Bootloader ====
 +
 +Sometimes it might be necessary to backup settings/​partitions from original firmware. Depending on the bootloader different strategies might be possible.
 +
 +The flash-chip is mapped to a start adress. With uboot it should be in settings
 +<​code>​
 +printenv
 +bdinfo
 +</​code>​
 +
 +  * memory dump to serial that is logged (uboot: //md// ; redboot: //dump//)
 +  * writing dumps to tftp or nfs
  
 ===== Restore Backup ===== ===== Restore Backup =====
Line 44: Line 89:
  
 ===== Backup your configuration ===== ===== Backup your configuration =====
 +You can backup configuration through the web interface, at System:​Backup / Flash Firmware:​Generate Archive. If the web interface is not available, connect using SSH and enter:
 <​code>​ <​code>​
-ssh root@openwrt "​cd ​/etc; tar cvz config"​ > openwrt.tar.gz+sysupgrade --create-backup ​/tmp/​backup-`cat /​proc/​sys/​kernel/​hostname`-`date +%F`.tar.gz; ls /​tmp/​backup*
 </​code>​ </​code>​
  
-You may also want to backup other filessuch as "​ppp"​ directory.+Now on your local computer, use scp to retreive the file: 
 +(Remember to use the ip of your OpenWRT device and the filename of your backup file.) 
 + 
 +<​code>​ 
 +scp root@192.168.1.1:/​tmp/​backup-openwrt-2014-08-26.tar.gz . 
 +</​code>​ 
 + 
 +You might also want to backup other files you have edited ​such as
 + 
 +   * /​etc/​ethers 
 +   * /home (if you added users) 
 +   * /​etc/​config/​firewall.user 
 +===== Backup your partition ===== 
 +You can do partition backup by using AOMEI Backupper. Launch this software.  
 + 
 +* click **Backup** tab and choose Partition Backup. 
 + 
 +* select partition which you'd like to backup and choose the destination where you'd put the image in. 
 + 
 +* click **Start Backup** to prompt this  process and wait till it reaches 100%, you can set more details under **Home** tab at the first interface.
doc/howto/generic.backup.1372841876.txt.bz2 · Last modified: 2013/07/03 10:57 by lorema