January 27, 2020, 10:37:29 pm

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


Backup the nand to disk or image?

Started by CubieNewb, December 18, 2013, 10:41:25 pm

Previous topic - Next topic

CubieNewb

Does anyone know of a way to backup the nand to an image or disk? I notice that the Phoenix suite has a backup function there, but it didn't work when I tried it.

rose28357

did you try dd ? it makes a bit wise copy of drive or partition.

maybe it is a good idea to do dd of nand from an linux booted from the sdcard. we will have a copy of a nand linux that has been shut down.

i belief that you can not write it back to nand with phönix.

kingneutron

--Maybe a little bit outside the box, but here is what I use to back up my Cubie:

o External dependencies:
o pv # Although this is optional; you can delete this whole line in the script if needed
o netcat
o a 2nd computer on the network running Linux and netcat, with HD space to store the backup
o Firewall port 32100 (arbitrary port) open on both PCs

BEGIN bkpsys2netcat

#!/bin/bash
# Network bkp to p3300 - run "nclisten" there 1st!
# HOME AND SQUID ARE INCLUDED!!

dpkg -l > ~/DEBInstalled.list

# XXX BACKUP DEB CACHE BEFORE RUNNING $0!!
apt-get clean

#echo '==Updatedb...'
#time updatedb

df -h /
df -h /mnt/squid

echo '==Backing up to p3300:32100...'
time tar \
  --exclude=/mnt/tmp --exclude=/mnt/usb3 --exclude=/media \
  --exclude=/SWAP1 \
  --exclude=/proc --exclude=/sys \
  --exclude=/cdrom --exclude=/floppy \
  --exclude=/.journal --exclude=/lost+found \
  -cpf - / \
  | pv -t -r -b -W -i 2 -B 25M \
  | netcat -w 10 10.0.0.33 32100

exit;

-----------

--On the 2nd PC (remote) side, CD to whatever dir you want to store the backup in, and run nclisten:

BEGIN nclisten
#!/bin/bash

# CD to where you want to be 1st!

inport=32100
#inport=5902
bkpdate=`date +%Y%m%d`

tofile="bkp-cubietruck-ARM-linaro--allgoodmods--b4-reboot-"$bkpdate".tar1.gz"
#tofile="bkp-laptop-dell-latitude-d610--p2000m--xp-pro-sp3-allgoodmods-100gig-sda1--"$bkpdate"--b4-autopatcher.ntfsclone1.gz"
#tofile="bkp-laptop-dell-studio--p2300m-sda3-centos6-64--"$bkpdate"--b4-updt.tar1.gz"

echo `basename $0`' +Listening port '$inport';'
echo -e ' +Tofile='$PWD'\ \n\r '$tofile

# Listen port for incoming file
# Uncompressed
#time netcat -l $inport \
#  |pv -t -r -b -W -i 5 -B 20M \
#  > $tofile

time netcat -l $inport \
  |pv -t -r -b -W -i 5 -B 50M \
  |gzip -1 \
  > $tofile

pwd
flist &

---------------

BEGIN flist
#!/bin/bash

# Go thru .tar.gz, .tar.bz2 in dir and list them to flist-file
function process () {
  args=$*
  echo $args

# if doing rezip, renice bzip2
renice +1 `pidof bzip2` 2>/dev/null

# Preserve existing output
  if [ -e "flist--$bn.txt" ]; then                                                                       
    echo '* Skipped '$bn
  else                                                                                                   
    time $compr -cd $args |tar tvf - > flist--$bn.txt
  fi
}
#function processbz2 () {
#  args=$*
#  echo $args
#  time tar tjvf $args > flist--$bn
#}

# If compare string not match any actual filename, move on
for i in *.tar.gz; do
  [ "$i" == "*.tar.gz" ] && break;
  bn=`basename $i .tar.gz`
  compr=gzip
  process $i
done

for i in *.tar1.gz; do
  [ "$i" == "*.tar1.gz" ] && break;
  bn=`basename $i .tar.gz`
  compr=gzip
  process $i
done

for i in *.tgz; do
  [ "$i" == "*.tgz" ] && break;
  bn=`basename $i .tgz`
  compr=gzip
  process $i
done

for i in *.tar.bz2; do
  [ "$i" == "*.tar.bz2" ] && break;
  bn=`basename $i .tar.bz2`
  compr=bzip2
  process $i
done

for i in *.tar; do
  [ "$i" == "*.tar" ] && break;
  bn=`basename $i .tar`
  compr=""
#  process $i
  time tar tvf $i > flist--$bn.txt
done