[Epic 4G Android Development] toadlife:
To all of the ROM makers here, please stop using those bonsai data-backup/data-restore scripts, as they don't work. I'm assuming they used to work since everyone here seems to be using them, but something has changed (maybe something in CWM 5.x?) and now all those data-backup and data-restore scripts do is make phones not work.

I've taking those scripts and rewritten them using the tar command. busybox's tar doesn't have many options, but it does preserve file permissions and ownership, so it makes for an adequate backup tool. HUGE thanks to SenseiSimple for the ideas and improvements. See SenseiSimple's post, here.

EDIT: Here is the final version!

updater-script BACKUP EXAMPLE

ui_print("************************************************");
ui_print(" TAR BACK UP / RESTORE EXAMPLE");
ui_print("************************************************");
show_progress(1.000, 0);
set_progress (0.100);

#EXTRACT BACKUP SCRIPT
ui_print("Preparing tools...");
package_extract_file("tools/busybox", "/tmp/busybox");
package_extract_file("tools/tar-backup", "/tmp/tar-backup");

set_perm(0, 0, 0755, "/tmp/tar-backup");
set_perm(0, 0, 0755, "/tmp/busybox");

#CREATE BACKUP
set_progress (0.350);
ui_print("Backing up - this may take a while...");
run_program("/sbin/mount","/sdcard");
run_program("/sbin/mount","/data");
run_program("/tmp/tar-backup","backup");
unmount("/data");

#RECOVER BACKUP
set_progress (0.600);
ui_print("Recovering backed up data...");
run_program("/sbin/mount","/data");
run_program("/tmp/tar-backup","recover");
# run_program("/tmp/tar-backup","recover","delete");
# run_program("/tmp/tar-backup","recover","archive");
unmount("/data");

set_progress(1.000);
show_progress(1.000, 0);

tar-backup script

edit the value of ROMName=YourROMName (you should only have to edit this file once for all your ROM versions, it's not version-dependent), that's it.

#!/tmp/busybox sh
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# License GPLv2+: GNU GPL version 2 <http://gnu.org/licenses/gpl.html>
#

# toadlife, SenseiSimple, XDA Community, Bonsai
# invoke with
# run_program("/tmp/tar-backup","backup");
# run_program("/tmp/tar-backup","recover" [,"delete"|"archive"]);

# - "delete" option deletes the backup file
# - "archive" option renames the backup file for archiving (otherwise, it is left alone and replaced on next backup/flash)

ROMName=MyAwesomeROM
platbuild=EI22

PATH=/tmp:/sbin:$PATH
datadir=/data
backdir=/sdcard/ROMBackup-$platbuild
backfile=$backdir/$ROMName.tgz
TEST="busybox test"; TAR="busybox tar"; MKDIR="busybox mkdir"

if [ "$1" = "backup" ]; then
rm /data/dalvik-cache/*
rm /data/lost+found/*
rm $backfile
if $TEST -d $datadir ; then
$TEST ! -d $backdir && $MKDIR $backdir
$TAR pczf $backfile $datadir
if $TEST $? -ne 0 ; then
echo "Backup failed!"; exit 1
else
echo "Backup completed"; exit 0
fi
fi
elif [ "$1" = "recover" ]; then
if $TEST -f $backfile; then
$TAR pxzf $backfile
if [ "$2" = "delete" ]; then
rm $backfile;
elif [ "$2" = "archive" ]; then
archdate=`date +%Y%m%d-%I%M`
archfile=$backdir/$ROMName-$archdate.tgz
mv $backfile $archfile
fi
echo "Restore Completed!"; exit 0
else
echo "Restore failed!"; exit 1
fi

else
echo "Backup - Invalid argument"; exit 1
fi

Example CWM package (unsigned) that uses the script.