 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Toker
Joined: 04 Nov 2004 Posts: 28
|
Posted: Mon Nov 29, 2004 10:52 am Post subject: easy mc backup |
|
|
I wrote a simple wrapper script for ps2client to easily do a complete backup of a memory card. It simply recurses through all the directories and creates an identical structure in the local directory.
| Code: |
#!/bin/bash
#
# wrapper for ps2client to do complete MC backup
#
# USAGE: mc-backup.sh [dest] [src-mc]
# [dest] is local destination directory. Default is "mc0.YYYY-MM-DD.HHMM"
# [src-mc] is memory card to backup. Default is "mc0:"
#
# no warranty... unlikely to break anything,
# no copyright... most people can whip this up in their sleep
#
PS2C="ps2client"
DATE="date"
AWK="awk"
Fcnt=0
Dcnt=0
# make sure we have what we need
for X in $PS2C $AWK $DATE ; do
Z=`$X --version`
if [ $? -eq 127 ]; then
echo "### ERROR: '$X' not found"
exit -1
fi
done
DoDir() { # $1 mc dir to process
PS2Cmd="$PS2C dir $1"
T=`$PS2Cmd`
if [ $? -ne 0 ]; then
echo -n "ERROR: '$PS2Cmd' returned: "
$PS2Cmd
echo "PS2 probably need to be reset by running 'ps2client reset'"
exit -1
fi
IFS=$'\x0A'$'\x0D'
G=`echo "$T" | awk ' \$1 ~ /^-r/ { A=substr($0,45); print A } '`
for F in `echo "$G"` ; do
Z=`$PS2C copyfrom "$1/$F" "$F"`
if [ $? -ne 0 ]; then echo "ERROR on copy."; fi
# change to ' echo "$Z" ' to get long output
echo $Z
let Fcnt+=1
done
unset IFS
for D in `$PS2Cmd | awk ' \$1 ~ /^d/ && \$5 != "." && \$5 != ".." { print $5 } '` ; do
echo "INFO: Descending into '$D' "
Descend $D $1
let Dcnt+=1
done
}
Descend () { # $1 dir name, $2 current dir
Z=`mkdir $1 2>&1`
if [ $? -ne 0 ]; then echo "ERROR: $Z"; exit -1; fi
cd $1
DoDir "$2/$1"
cd ..
}
SRC="mc0:" # default source (mc) ($2)
DEST="$SRC."`$DATE "+%F.%k%M"` # default dest (local dir) ($1)
if [ -n "$1" ] ; then DEST=$1; fi
if [ -n "$2" ] ; then SRC=$2; fi
echo "Backing up '$SRC' to '$DEST'"
Z=`mkdir $DEST 2>&1`
if [ $? -ne 0 ]; then echo "ERROR: $Z"; exit -1; fi
cd $DEST
DoDir $SRC
echo
echo "SUMMARY: $Dcnt directories, $Fcnt files processed."
|
|
|
| Back to top |
|
 |
ooPo Site Admin
Joined: 17 Jan 2004 Posts: 2032 Location: Canada
|
Posted: Mon Nov 29, 2004 4:00 pm Post subject: |
|
|
| Aha! Good stuff. |
|
| Back to top |
|
 |
Toker
Joined: 04 Nov 2004 Posts: 28
|
Posted: Sun Dec 05, 2004 11:08 am Post subject: |
|
|
I have been looking into why I needed to put the error-check for dir/copy failing.
It appears it is related to 'dopen'.
If I do 'dir mc0:' repetitively, it will fail on the 50th attempt.
Copying a file with copyfrom never fails (1500+ repeats -- ~175MB in all).
I also tried hdd0: and mass: (just for the 'dir' test), and mass: has the same problem, but not hdd0. (I'm using the napalm usbd.irx, and the usb_mass.irx from cvs).
I'm certain the problem isn't in ps2client, ps2link, or ps2netfs. (but maybe iomanx? filexio?)
I've searched but haven't found anything relevant (except the drivers on the rom do have bugs, such as the rmdir function) yet, so if anyone knows anything, I'd appreciate it... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|