Backup

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Undo revision 82184 by Mefio (Talk):spam)
 
(60 intermediate revisions by 33 users not shown)
Line 1: Line 1:
 +
== Backing up just PIM data ==
 +
 +
The following applies to all Qtopia PIM suite based derivations (FDOM, 2008.8, Qtopia). PIM data covers:
 +
 +
* Contacts, calendar appointments, and tasks
 +
* E-Mails and text messages
 +
 +
To make a backup which can be easily restored later on use secure copy:
 +
 +
scp -pr root@192.168.0.202:~/Applications/ .
 +
scp -pr root@192.168.0.202:~/Documents/ .
 +
 +
To restore do the reverse:
 +
 +
scp -pr Applications root@192.168.0.202:~/
 +
scp -pr Documents root@192.168.0.202:~/
 +
 +
Make sure you restart to allow the Qtopia PIM suite to see the changes:
 +
 +
reboot
 +
 +
This way we can flash applicable distributions with minimal effort without loosing important data. To access the PIM data on the computer take a look at the following files and folders:
 +
 +
* Contacts, calendar appointments, and tasks are kept in <tt>~/Applications/Qtopia/qtopia_db.sqlite</tt>.
 +
* E-Mails and text messages are kept in <tt>~/Applications/qtmail/mail/</tt>.
 +
 +
== Backing up just /home/root ==
 +
 +
To backup the home folder (all your personal files in theory).
 +
 +
From the desktop pc run:
 +
 +
ssh root@phone 'tar -cpz /home/root' > moko-home-`date +%Y%m%d-%H%M%S`.tar.gz
 +
 +
Where '''<tt>phone</tt>''' is the ip address of your phone (192.168.0.202).
 +
 +
Personally I added an entry to /etc/hosts so the above works for me. I also added the desktop key to /home/root/.ssh/authorized_keys on the phone as per the instructions in [[USB_Networking#SSH_Keys]].
 +
 +
If you want to check what is in the backup, run the following, replacing the filename with what was just created.
 +
 +
tar -tzf moko-home-20080802-203108.tar.gz | less
 +
 +
[http://timwise.wikispaces.com/my+neo+freerunner reference]
 +
 +
== Backing up everything ==
 +
 +
You may either :
 +
* Backup the flash contents, in order to be able to restore (see below)
 +
* or move the system to SD to be able to boot it from SD in case of need. See [[Moving current system from flash to SD]]
 +
 +
=== Backing-up flash images ===
 +
 +
{{note|Upload support is currently broken - [http://docs.openmoko.org/trac/ticket/676 #676], [http://docs.openmoko.org/trac/ticket/1843 #1843]}}
 +
 
You will need the [[Dfu-util]] to make a backup of your existing image.
 
You will need the [[Dfu-util]] to make a backup of your existing image.
  
As when [[Flashing_the_Neo_FreeRunner|flashing]], you will need to be in [[FreeRunner/Buttons_and_LEDs#Basic_Button_Usage|U-Boot in the NOR Flash]].
+
As when [[Flashing_the_Neo_FreeRunner|flashing]], you will need to be in [[Booting_the_Neo_FreeRunner#Log_into_U-Boot_in_the_NOR_Flash|U-Boot in the NOR Flash]]. Log into the NOR uBoot menu and select ''Set console to USB'' (for FreeRunner just stay in NOR uBoot menu, do not select or enter anything). Now you will be able to flash, make backups of your FreeRunner or query the FreeRunner with [[Dfu-util|dfu-util]].  Backup is fairly slow; it took over ten minutes to back up a 247 MB rootfs.
 +
 
 +
It is important that you connect the USB cable directly from your computer to your phone.  If there is a hub between them, backup (and flashing) will mostly likely fail.
  
THIS WILL TAKE AWHILE.  The rootfs will take significantly longer than the kernel.
+
{{note|On a Windows host, omit the "./" or "sudo ./" that precedes the commands listed on this page}}
  
 
<pre>
 
<pre>
./dfu-util -a kernel -R -U good-kernel.bin
+
sudo ./dfu-util -a kernel -R -U good-kernel.bin
./dfu-util -a rootfs -R -U good-rootfs.jffs2
+
sudo ./dfu-util -a rootfs -R -U good-rootfs.jffs2
 +
sudo ./dfu-util -a splash -R -U good-splash.bin
 +
sudo ./dfu-util -a u-boot -R -U good-u-boot.bin
 +
sudo ./dfu-util -a u-boot_env -R -U good-u-boot_env.bin
 
</pre>
 
</pre>
  
Here is what my successful output looked like...
+
Here is what a successful dfu-util backup run looks like:
  
 
on the host PC:
 
on the host PC:
 
<pre>
 
<pre>
 
$ sudo ./dfu-util -a kernel -R -U good-kernel.img
 
$ sudo ./dfu-util -a kernel -R -U good-kernel.img
dfu-util - (C) 2007 by OpenMoko Inc.
+
dfu-util - (C) 2007 by Openmoko Inc.
 
This program is Free Software and has ABSOLUTELY NO WARRANTY
 
This program is Free Software and has ABSOLUTELY NO WARRANTY
  
Line 31: Line 90:
 
Transfer Size = 0x1000
 
Transfer Size = 0x1000
 
Resetting USB to switch back to runtime mode
 
Resetting USB to switch back to runtime mode
$ sudo ./dfu-util -a rootfs -R -U good-rootfs.jffs2
+
</pre>
dfu-util - (C) 2007 by OpenMoko Inc.
+
 
 +
on the FreeRunner:
 +
<pre>
 +
DFU: Switching to DFU Mode
 +
DEVICE_CONFIGURED: 1
 +
Starting DFU Upload of partition 'kernel'
 +
DEVICE_CONFIGURED: 1
 +
</pre>
 +
 
 +
A failed run of dfu-util looks like this:
 +
<pre>
 +
dfu-util - (C) 2007 by Openmoko Inc.
 
This program is Free Software and has ABSOLUTELY NO WARRANTY
 
This program is Free Software and has ABSOLUTELY NO WARRANTY
  
 
Opening USB Device 0x0000:0x0000...
 
Opening USB Device 0x0000:0x0000...
Found Runtime: [0x1d50:0x5119] devnum=16, cfg=0, intf=0, alt=6, name="rootfs"
+
Claiming USB DFU Runtime Interface...
 +
Determining device status: state = appIDLE, status = 0
 +
Device really in Runtime Mode, send DFU detach request...
 +
Resetting USB...
 +
Opening USB Device...
 +
Found Runtime: [0x1d50:0x5119] devnum=20, cfg=0, intf=0, alt=6, name="rootfs"
 
Claiming USB DFU Interface...
 
Claiming USB DFU Interface...
 
Setting Alternate Setting ...
 
Setting Alternate Setting ...
Determining device status: state = dfuERROR, status = 14
 
dfuERROR, clearing status
 
 
Determining device status: state = dfuIDLE, status = 0
 
Determining device status: state = dfuIDLE, status = 0
 
dfuIDLE, continuing
 
dfuIDLE, continuing
 
Transfer Size = 0x1000
 
Transfer Size = 0x1000
Resetting USB to switch back to runtime mode
+
dfu_upload error -110
 
</pre>
 
</pre>
 +
And shows demsg errors like this:
 +
<pre>
 +
usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd dfu-util rqt 161 rq 2 len 4096 ret -110
 +
</pre>
 +
This error is detected within the Linux USB stack (drivers/usb/core/message.c) and looking at
 +
errno.h for the negatived error status number, the reason is e.g.
 +
{|
 +
| 110 || ETIMEDOUT || Connection timed out
 +
|-
 +
|  84 || EILSEQ    || Illegal byte sequence
 +
|-
 +
| 108 || ESHUTDOWN || Cannot send after transport endpoint shutdown
 +
|-
 +
| ... ||          ||
 +
|}
 +
Insure yourself, that you connect the FR directly to the computer (without any USB hubs), if you experience timed out connections
 +
and use the
  
Despite the fact that there was a device status with state=dfuERROR, everything seems to have worked.
+
dfu-util -d [[USB Product IDs|0x1d50:0x5119]] ...
  
on the FreeRunner:
+
option, if the FR is not detected properly.
 +
 
 +
=== Backing-up flash images (alternative) ===
 +
 
 +
On the device:
 
<pre>
 
<pre>
DFU: Switching to DFU Mode
+
mkdir /var/tmp/root
DEVICE_CONFIGURED: 1
+
mount /dev/root /var/tmp/root
Starting DFU Upload of partition 'kernel'
+
DEVICE_CONFIGURED: 1
+
Starting DFU Upload of partition 'rootfs'
+
 
</pre>
 
</pre>
  
I could backup the kernel of my GTA02  but trying to use this method to backup the rootfs failed several times....
+
If you have om2008.9 you have to use:
dfu-util - (C) 2007 by OpenMoko Inc.
+
<pre>
This program is Free Software and has ABSOLUTELY NO WARRANTY
+
mount -t jffs2 /dev/mtdblock6 /var/tmp/root
 +
</pre>
 +
 
 +
On your workstation:
 +
<pre>
 +
ssh root@192.168.0.202 "mkfs.jffs2 -d /var/tmp/root -e 128 --pad --no-cleanmarkers -x lzo" | pv -W > rootfs.jffs2
 +
</pre>
 +
(The "| pv -W" is optional, it just gives you something to watch as the bytes fly by.)
 +
 
 +
On the device:
 +
<pre>
 +
umount /var/tmp/root
 +
</pre>
 +
 
 +
=== Backing-up in a tar archive ===
 +
 
 +
ssh root@192.168.0.202 "tar c /bin /etc /home /lib /opt /sbin /tmp /usr /var" | pv -s 2200000 -W > rootfs.tar
 +
(The "| pv -W" is optional, it just gives you something to watch as the bytes fly by; the "-s" option presume you're transferring 2200000 bytes of data)
 +
 
 +
Extract it and use <code>mkfs.jffs2</code> if you want convert it to a jffs2 image.
 +
 
 +
==Backup Scripts==
 +
 
 +
If you plan on backing up frequently, using a script will simplify the process:
 +
 
 +
===Simple backup script===
 +
 
 +
This script works well if you want to configure it to backup always the same device.
 +
 
 +
<pre>
 +
#!/bin/sh
 +
#
 +
# Back up all partitions of the phone to a backup directory,
 +
# adding today's date to the saved filenames.
 +
 
 +
DATE=`date +%Y-%m-%d`
 +
DFU=./dfu-util
 +
BACKUP_DIR=bak/
 +
 
 +
${DFU} -a kernel -R -U ${BACKUP_DIR}kernel-${DATE}.bin
 +
${DFU} -a rootfs -R -U ${BACKUP_DIR}rootfs-${DATE}.jffs2
 +
${DFU} -a splash -R -U ${BACKUP_DIR}splash-${DATE}.bin
 +
${DFU} -a u-boot -R -U ${BACKUP_DIR}u-boot-${DATE}.bin
 +
${DFU} -a u-boot_env -R -U ${BACKUP_DIR}u-boot_env-${DATE}.bin
 +
</pre>
 +
 
 +
===Interactive script===
 +
 
 +
This script is based on the above "Simple backup script" (by unknown). It does the backup of what you want and choose promting you for choices. Enjoy it! test it! contribute! You can find us at /server irc.freenode.net /j #openmoko and we'll be pleased to accept you help (ideas || code).                              
 +
 
 +
NOTE that the script works for me(tm) but it still needs some love. especially on traps and catches for wrong choices.
 +
 
 +
<pre>
 +
#!/bin/bash
 +
 
 +
#############################################################################################################
 +
##                                                                                                        ##
 +
## This script is Free Software, it's licensed under the GPLv3 and has ABSOLUTELY NO WARRANTY             ##
 +
## you can find and read the complete version of the GPLv3 @ http://www.gnu.org/licenses/gpl.html          ##
 +
##                                                                                                        ##
 +
## Q: what does this script do?                                                                            ##
 +
## A: the script back up all partitions of the phone to a backup directory, interactively,                ##
 +
##    adding today's date to the saved filenames.                                                          ##
 +
##                                                                                                        ##
 +
## IMPORTANT:!!! REMEMBER TO RUN THIS SCRIPT AS ROOT SINCE dfu-util HAS TO BE USED AS ROOT!!!              ##
 +
##                                                                                                        ##
 +
## based on the orginal simple backup script at http://wiki.openmoko.org/wiki/Backup                      ##
 +
##                                                                                                        ##
 +
## this version has been conceived and written by cga, x77686d, Infoport, jomat at /server irc.freenode.net##
 +
## /j #openmoko,#bash and my collegue aubba @ work.                                                        ##
 +
##                                                                                                        ##
 +
## for any suggestions and contributions contact cga (or one of the above) in the #openmoko channel        ##
 +
##                                                                                                        ##
 +
#############################################################################################################
 +
 
 +
## let's roll!!
 +
 
 +
## sets the date format for the date in the backup file, change accordingly to your local custom if you need
 +
DATE=`date +%d-%m-%Y`
 +
 
 +
## here the scripts try to find the dfu-util binary and set it as the DFU var:
 +
if which dfu-util >/dev/null ; then
 +
echo
 +
echo "dfu-util found in your path"
 +
echo
 +
## 1 the function use this if you placed/linked dfu-util in your $PATH
 +
DFU=dfu-util
 +
 
 +
elif ls dfu-util >/dev/null ; then
 +
echo
 +
echo "dfu-util found in current directory"
 +
echo
 +
## or 2 use following line if dfu-util is placed in the same directory where you run the script
 +
DFU=./dfu-util
 +
 +
else
 +
## or 3 if the script doesn't find dfu-util shows the link for installing it and exit
 +
echo
 +
echo "dfu-util NOT found! install and use howto @ http://wiki.openmoko.org/wiki/Dfu-util"
 +
echo
 +
exit 1
 +
fi
 +
 
 +
## here we get the hex code for devices found with dfu-util --list
 +
## the hex code is grabbed and the name of the device is shown accordingly and you are prompetd to chose the right one:
 +
echo
 +
echo 'these are the devices i found:'
 +
echo
 +
for device in `${DFU} --list | grep 0x | cut -f3 -d' ' | tr -d '[]'` ; do
 +
if [ "$device" == '0x1457:0x5119' ] ; then
 +
echo 'Neo 1973'
 +
elif [ "$device" == '0x1d50:0x5119' ] ; then
 +
echo "Neo FreeRunner"
 +
else
 +
echo 'other device found, DO NOT use dfu-util on this!!! it might bork it...'
 +
exit 1
 +
fi
 +
done | nl
 +
echo
 +
echo 'choose the device to backup:'
 +
echo
 +
read selection
 +
HEX=$(${DFU} --list | grep 0x | head -n $selection | tail -1 | cut -f3 -d' ' | tr -d '[]')
 +
 
 +
## use the built-in read command to ask you and use the directory for the backup
 +
while [ -z "$BACKUP_DIR" ] ; do
 +
echo
 +
read -e -p $"enter the directory for the backup:" BACKUP_DIR
 +
echo
 +
 
 +
## chek wether the dir exist and proceed, else create it and proceed.
 +
if [ ! -d "$BACKUP_DIR" ] ; then
 +
echo
 +
echo -n "$BACKUP_DIR does not exist, create it? [Y/n] "
 +
echo
 +
read CREATE_DIR
 +
if [ x"$CREATE_DIR" = xy -o x"$CREATE_DIR" = xY -o -z "$CREATE_DIR" ] ; then
 +
mkdir -p -v "${BACKUP_DIR}"
 +
else
 +
BACKUP_DIR=
 +
fi
 +
fi
 +
done
 +
 
 +
## here you get prompted to chose the backup you want, you can backup single files or all of them.
 +
echo
 +
echo 'choose the component to backup from the list:'
 +
echo
 +
 
 +
select howto in kernel splash u-boot u-boot_env rootfs all quit; do
 +
if [ "$howto" == "kernel" -o "$howto" == "all" ] ; then
 +
${DFU} -d ${HEX} -a kernel -R -U ${BACKUP_DIR}/kernel-${DATE}.bin
 +
fi
 +
if [ "$howto" == "splash" -o "$howto" == "all" ] ; then
 +
${DFU} -d ${HEX} -a splash -R -U ${BACKUP_DIR}/splash-${DATE}.bin
 +
fi
 +
if [ "$howto" == "u-boot" -o "$howto" == "all" ] ; then
 +
${DFU} -d ${HEX} -a u-boot -R -U ${BACKUP_DIR}/u-boot-${DATE}.bin
 +
fi
 +
if [ "$howto" == "u-boot_env" -o "$howto" == "all" ] ; then
 +
${DFU} -d ${HEX} -a u-boot_env -R -U ${BACKUP_DIR}/u-boot_env-${DATE}.bin
 +
fi
 +
if [ "$howto" == "rootfs" -o "$howto" == "all" ] ; then
 +
${DFU} -d ${HEX} -a rootfs -R -U ${BACKUP_DIR}/rootfs-${DATE}.jffs2
 +
fi
 +
if [ "$howto" == "quit" ] ; then
 +
exit 0
 +
fi
 +
echo
 +
echo 'the component(s) has/have been backed up, what next? (press enter for menu)'
 +
echo
 +
done
 +
 
 +
exit 0
 +
 
 +
</pre>
 +
 
 +
=== Pretty GUI Script ===
 +
 
 +
[[NeoTool]] is a zenity-based script which allows you to both backup and Flash your device from a pretty GUI. It uses both the dfu-util method and the alternate method described on this page, and can produce flashable images of everything including rootfs. Check it out.
 +
 
 +
== Backing up the incremental rsync hardlink way ==
 +
 
 +
Following is a very simple implementation of
 +
[http://www.mikerubel.org/computers/rsync_snapshots/ incremental rsync snapshots with hardlinks]. Just put it to /etc/cron.daily/backup-neo
 +
on your PC and setup ssh keys between your PC and neo. It will then
 +
daily try to backup all files in the / partition. Each successful
 +
backup is hardlinked under a timestamped directory so you can access
 +
old backups easily. In fact, you can even NFS mount /backup/neo to
 +
phone and then chroot inside the backups to run programs in the
 +
backup'ed environment.
 +
#!/bin/bash
 +
# /etc/cron.daily/backup-neo
 +
rsync --delete -ax --numeric-ids 192.168.0.202:/ /backup/neo/latest 2>  /dev/null
 +
ret=$?
 
   
 
   
  Opening USB Device 0x0000:0x0000...
+
  case $ret in
  Claiming USB DFU Runtime Interface...
+
  0)
Determining device status: state = appIDLE, status = 0
+
        # backup done, let's save it
Device really in Runtime Mode, send DFU detach request...
+
        cp -al /backup/neo/latest /backup/neo/`date -I`
  Resetting USB...
+
        ;;
  Opening USB Device...
+
  12)
Found Runtime: [0x1d50:0x5119] devnum=20, cfg=0, intf=0, alt=6, name="rootfs"
+
        # neo was not at home
Claiming USB DFU Interface...
+
        ;;
  Setting Alternate Setting ...
+
  *)
Determining device status: state = dfuIDLE, status = 0
+
        echo "backup failed with return value $ret"
  dfuIDLE, continuing
+
        ;;
  Transfer Size = 0x1000
+
  esac
  dfu_upload error -110
+
 
 +
== Backing up internal flash when booted on external SD-card ==
 +
 
 +
  #Freerunner
 +
  mkdir internal_flash
 +
  mount /dev/mtdblock6 internal_flash -t jffs2
 +
 
 +
Now you can pack directory or copy selected files out from it.
 +
 
 +
(This mounting is usefull also if your internal operating system is non-bootable. You can get files out or even repair the system using operating system on external card.)
  
In demsg I get this error
+
== Weblinks ==
usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd dfu-util rqt 161 rq 2 len 4096 ret -110
+
* [http://www.oesf.org/forum/index.php?showtopic=25994#entry178835 read jffs file system on pc]
  
I have not been able to backup rootfs using this method.
+
[[Category:PIM]]
[[category:Software]]
+
[[category:Advanced End User]]
[[category:Technical]]
+
[[Category:Flashing Openmoko]]

Latest revision as of 20:51, 29 August 2010

Contents

[edit] Backing up just PIM data

The following applies to all Qtopia PIM suite based derivations (FDOM, 2008.8, Qtopia). PIM data covers:

* Contacts, calendar appointments, and tasks
* E-Mails and text messages

To make a backup which can be easily restored later on use secure copy:

scp -pr root@192.168.0.202:~/Applications/ .
scp -pr root@192.168.0.202:~/Documents/ .

To restore do the reverse:

scp -pr Applications root@192.168.0.202:~/
scp -pr Documents root@192.168.0.202:~/

Make sure you restart to allow the Qtopia PIM suite to see the changes:

reboot

This way we can flash applicable distributions with minimal effort without loosing important data. To access the PIM data on the computer take a look at the following files and folders:

  • Contacts, calendar appointments, and tasks are kept in ~/Applications/Qtopia/qtopia_db.sqlite.
  • E-Mails and text messages are kept in ~/Applications/qtmail/mail/.

[edit] Backing up just /home/root

To backup the home folder (all your personal files in theory).

From the desktop pc run:

ssh root@phone 'tar -cpz /home/root' > moko-home-`date +%Y%m%d-%H%M%S`.tar.gz

Where phone is the ip address of your phone (192.168.0.202).

Personally I added an entry to /etc/hosts so the above works for me. I also added the desktop key to /home/root/.ssh/authorized_keys on the phone as per the instructions in USB_Networking#SSH_Keys.

If you want to check what is in the backup, run the following, replacing the filename with what was just created.

tar -tzf moko-home-20080802-203108.tar.gz | less

reference

[edit] Backing up everything

You may either :

[edit] Backing-up flash images

NOTE: Upload support is currently broken - #676, #1843


You will need the Dfu-util to make a backup of your existing image.

As when flashing, you will need to be in U-Boot in the NOR Flash. Log into the NOR uBoot menu and select Set console to USB (for FreeRunner just stay in NOR uBoot menu, do not select or enter anything). Now you will be able to flash, make backups of your FreeRunner or query the FreeRunner with dfu-util. Backup is fairly slow; it took over ten minutes to back up a 247 MB rootfs.

It is important that you connect the USB cable directly from your computer to your phone. If there is a hub between them, backup (and flashing) will mostly likely fail.

NOTE: On a Windows host, omit the "./" or "sudo ./" that precedes the commands listed on this page


sudo ./dfu-util -a kernel -R -U good-kernel.bin
sudo ./dfu-util -a rootfs -R -U good-rootfs.jffs2
sudo ./dfu-util -a splash -R -U good-splash.bin
sudo ./dfu-util -a u-boot -R -U good-u-boot.bin
sudo ./dfu-util -a u-boot_env -R -U good-u-boot_env.bin

Here is what a successful dfu-util backup run looks like:

on the host PC:

$ sudo ./dfu-util -a kernel -R -U good-kernel.img
dfu-util - (C) 2007 by Openmoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=12, cfg=0, intf=0, alt=3, name="kernel"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
Resetting USB to switch back to runtime mode

on the FreeRunner:

DFU: Switching to DFU Mode
DEVICE_CONFIGURED: 1
Starting DFU Upload of partition 'kernel'
DEVICE_CONFIGURED: 1

A failed run of dfu-util looks like this:

dfu-util - (C) 2007 by Openmoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=20, cfg=0, intf=0, alt=6, name="rootfs"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
dfu_upload error -110

And shows demsg errors like this:

usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd dfu-util rqt 161 rq 2 len 4096 ret -110

This error is detected within the Linux USB stack (drivers/usb/core/message.c) and looking at errno.h for the negatived error status number, the reason is e.g.

110 ETIMEDOUT Connection timed out
84 EILSEQ Illegal byte sequence
108 ESHUTDOWN Cannot send after transport endpoint shutdown
...

Insure yourself, that you connect the FR directly to the computer (without any USB hubs), if you experience timed out connections and use the

dfu-util -d 0x1d50:0x5119 ...

option, if the FR is not detected properly.

[edit] Backing-up flash images (alternative)

On the device:

mkdir /var/tmp/root
mount /dev/root /var/tmp/root

If you have om2008.9 you have to use:

mount -t jffs2 /dev/mtdblock6 /var/tmp/root

On your workstation:

ssh root@192.168.0.202 "mkfs.jffs2 -d /var/tmp/root -e 128 --pad --no-cleanmarkers -x lzo" | pv -W > rootfs.jffs2

(The "| pv -W" is optional, it just gives you something to watch as the bytes fly by.)

On the device:

umount /var/tmp/root

[edit] Backing-up in a tar archive

ssh root@192.168.0.202 "tar c /bin /etc /home /lib /opt /sbin /tmp /usr /var" | pv -s 2200000 -W > rootfs.tar

(The "| pv -W" is optional, it just gives you something to watch as the bytes fly by; the "-s" option presume you're transferring 2200000 bytes of data)

Extract it and use mkfs.jffs2 if you want convert it to a jffs2 image.

[edit] Backup Scripts

If you plan on backing up frequently, using a script will simplify the process:

[edit] Simple backup script

This script works well if you want to configure it to backup always the same device.

#!/bin/sh
#
# Back up all partitions of the phone to a backup directory,
# adding today's date to the saved filenames.

DATE=`date +%Y-%m-%d`
DFU=./dfu-util
BACKUP_DIR=bak/

${DFU} -a kernel -R -U ${BACKUP_DIR}kernel-${DATE}.bin
${DFU} -a rootfs -R -U ${BACKUP_DIR}rootfs-${DATE}.jffs2
${DFU} -a splash -R -U ${BACKUP_DIR}splash-${DATE}.bin
${DFU} -a u-boot -R -U ${BACKUP_DIR}u-boot-${DATE}.bin
${DFU} -a u-boot_env -R -U ${BACKUP_DIR}u-boot_env-${DATE}.bin

[edit] Interactive script

This script is based on the above "Simple backup script" (by unknown). It does the backup of what you want and choose promting you for choices. Enjoy it! test it! contribute! You can find us at /server irc.freenode.net /j #openmoko and we'll be pleased to accept you help (ideas || code).

NOTE that the script works for me(tm) but it still needs some love. especially on traps and catches for wrong choices.

#!/bin/bash

#############################################################################################################
##                                                                                                         ##
## This script is Free Software, it's licensed under the GPLv3 and has ABSOLUTELY NO WARRANTY              ##
## you can find and read the complete version of the GPLv3 @ http://www.gnu.org/licenses/gpl.html          ##
##                                                                                                         ##
## Q: what does this script do?                                                                            ##
## A: the script back up all partitions of the phone to a backup directory, interactively,                 ## 
##    adding today's date to the saved filenames.                                                          ##
##                                                                                                         ##
## IMPORTANT:!!! REMEMBER TO RUN THIS SCRIPT AS ROOT SINCE dfu-util HAS TO BE USED AS ROOT!!!              ##
##                                                                                                         ##
## based on the orginal simple backup script at http://wiki.openmoko.org/wiki/Backup                       ##
##                                                                                                         ##
## this version has been conceived and written by cga, x77686d, Infoport, jomat at /server irc.freenode.net##
## /j #openmoko,#bash and my collegue aubba @ work.                                                        ##
##                                                                                                         ##
## for any suggestions and contributions contact cga (or one of the above) in the #openmoko channel        ##
##                                                                                                         ##
#############################################################################################################

## let's roll!!

## sets the date format for the date in the backup file, change accordingly to your local custom if you need
DATE=`date +%d-%m-%Y`

## here the scripts try to find the dfu-util binary and set it as the DFU var:
if which dfu-util >/dev/null ; then
	echo
	echo "dfu-util found in your path"
	echo
	## 1 the function use this if you placed/linked dfu-util in your $PATH
	DFU=dfu-util

elif ls dfu-util >/dev/null ; then
	echo
	echo "dfu-util found in current directory" 
	echo
	## or 2 use following line if dfu-util is placed in the same directory where you run the script
	DFU=./dfu-util
	 
else
	## or 3 if the script doesn't find dfu-util shows the link for installing it and exit
	echo
	echo "dfu-util NOT found! install and use howto @ http://wiki.openmoko.org/wiki/Dfu-util"
	echo
	exit 1
fi

## here we get the hex code for devices found with dfu-util --list 
## the hex code is grabbed and the name of the device is shown accordingly and you are prompetd to chose the right one:
echo
echo 'these are the devices i found:' 
echo
for device in `${DFU} --list | grep 0x | cut -f3 -d' ' | tr -d '[]'` ; do
	if [ "$device" == '0x1457:0x5119' ] ; then
		echo 'Neo 1973'
	elif [ "$device" == '0x1d50:0x5119' ] ;	then
		echo "Neo FreeRunner"
	else
		echo 'other device found, DO NOT use dfu-util on this!!! it might bork it...'
		exit 1
	fi
done | nl
echo
echo 'choose the device to backup:' 
echo
read selection
HEX=$(${DFU} --list | grep 0x | head -n $selection | tail -1 | cut -f3 -d' ' | tr -d '[]') 

## use the built-in read command to ask you and use the directory for the backup
while [ -z "$BACKUP_DIR" ] ; do
	echo
	read -e -p $"enter the directory for the backup:" BACKUP_DIR
	echo

	## chek wether the dir exist and proceed, else create it and proceed.
	if [ ! -d "$BACKUP_DIR" ] ; then
		echo
		echo -n "$BACKUP_DIR does not exist, create it? [Y/n] "
		echo
		read CREATE_DIR
		if [ x"$CREATE_DIR" = xy -o x"$CREATE_DIR" = xY -o -z "$CREATE_DIR" ] ; then
			mkdir -p -v "${BACKUP_DIR}"
		else
			BACKUP_DIR=
		fi
	fi
done

## here you get prompted to chose the backup you want, you can backup single files or all of them.
echo
echo 'choose the component to backup from the list:'
echo

select howto in kernel splash u-boot u-boot_env rootfs all quit; do
	if [ "$howto" == "kernel" -o "$howto" == "all" ] ; then
		${DFU} -d ${HEX} -a kernel -R -U ${BACKUP_DIR}/kernel-${DATE}.bin
	fi
	if [ "$howto" == "splash" -o "$howto" == "all" ] ; then
		${DFU} -d ${HEX} -a splash -R -U ${BACKUP_DIR}/splash-${DATE}.bin
	fi
	if [ "$howto" == "u-boot" -o "$howto" == "all" ] ; then
		${DFU} -d ${HEX} -a u-boot -R -U ${BACKUP_DIR}/u-boot-${DATE}.bin
	fi
	if [ "$howto" == "u-boot_env" -o "$howto" == "all" ] ; then
		${DFU} -d ${HEX} -a u-boot_env -R -U ${BACKUP_DIR}/u-boot_env-${DATE}.bin
	fi
	if [ "$howto" == "rootfs" -o "$howto" == "all" ] ; then
		${DFU} -d ${HEX} -a rootfs -R -U ${BACKUP_DIR}/rootfs-${DATE}.jffs2
	fi
	if [ "$howto" == "quit" ] ; then
		exit 0
	fi
	echo
	echo 'the component(s) has/have been backed up, what next? (press enter for menu)'
	echo
done

exit 0

[edit] Pretty GUI Script

NeoTool is a zenity-based script which allows you to both backup and Flash your device from a pretty GUI. It uses both the dfu-util method and the alternate method described on this page, and can produce flashable images of everything including rootfs. Check it out.

[edit] Backing up the incremental rsync hardlink way

Following is a very simple implementation of incremental rsync snapshots with hardlinks. Just put it to /etc/cron.daily/backup-neo on your PC and setup ssh keys between your PC and neo. It will then daily try to backup all files in the / partition. Each successful backup is hardlinked under a timestamped directory so you can access old backups easily. In fact, you can even NFS mount /backup/neo to phone and then chroot inside the backups to run programs in the backup'ed environment.

#!/bin/bash
# /etc/cron.daily/backup-neo
rsync --delete -ax --numeric-ids 192.168.0.202:/ /backup/neo/latest 2>  /dev/null
ret=$?

case $ret in
0)
        # backup done, let's save it
        cp -al /backup/neo/latest /backup/neo/`date -I`
        ;;
12)
        # neo was not at home
        ;;
*)
        echo "backup failed with return value $ret"
        ;;
esac

[edit] Backing up internal flash when booted on external SD-card

#Freerunner
mkdir internal_flash
mount /dev/mtdblock6 internal_flash -t jffs2

Now you can pack directory or copy selected files out from it.

(This mounting is usefull also if your internal operating system is non-bootable. You can get files out or even repair the system using operating system on external card.)

[edit] Weblinks

Personal tools

You will need the Dfu-util to make a backup of your existing image.

As when flashing, you will need to be in U-Boot in the NOR Flash.

THIS WILL TAKE AWHILE. The rootfs will take significantly longer than the kernel.

./dfu-util -a kernel -R -U good-kernel.bin
./dfu-util -a rootfs -R -U good-rootfs.jffs2

Here is what my successful output looked like...

on the host PC:

$ sudo ./dfu-util -a kernel -R -U good-kernel.img
dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=12, cfg=0, intf=0, alt=3, name="kernel"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
Resetting USB to switch back to runtime mode
$ sudo ./dfu-util -a rootfs -R -U good-rootfs.jffs2
dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Found Runtime: [0x1d50:0x5119] devnum=16, cfg=0, intf=0, alt=6, name="rootfs"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuERROR, status = 14
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
Resetting USB to switch back to runtime mode

Despite the fact that there was a device status with state=dfuERROR, everything seems to have worked.

on the FreeRunner:

DFU: Switching to DFU Mode
DEVICE_CONFIGURED: 1
Starting DFU Upload of partition 'kernel'
DEVICE_CONFIGURED: 1
Starting DFU Upload of partition 'rootfs'

I could backup the kernel of my GTA02 but trying to use this method to backup the rootfs failed several times....

dfu-util - (C) 2007 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0000:0x0000...
Claiming USB DFU Runtime Interface... 
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB... 
Opening USB Device...
Found Runtime: [0x1d50:0x5119] devnum=20, cfg=0, intf=0, alt=6, name="rootfs"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x1000
dfu_upload error -110

In demsg I get this error

usb 5-2: usbfs: USBDEVFS_CONTROL failed cmd dfu-util rqt 161 rq 2 len 4096 ret -110

I have not been able to backup rootfs using this method.