Sam Widges
Active Member
OK, this is hot off the presses and is very much work in progress...
My HDR-T2 has been on the fritz for a while now and several posts on the forum make me think that the hard drive is on the way out. Apart from the fact that we only bought the dratted thing in February, how do we go about rescuing the contents before it goes back for repair?
Well, the answer seems to be that we need:
1) Custom firmware
2) Auto-unprotect installed and running
3) An external hard drive with enough space that you can write to
4) A cunning script to save you lots of time
Assuming that you can sort steps 1-3, here's my first cut at step 4:
progbackup.sh
It's a half-baked script but it seems to be working fairly well at the moment. The key points are:
1) It'll help you to not shoot yourself in the foot when choosing a target backup drive, but it's still possible if you try hard enough (nothing is foolproof to a sufficiently talented fool)
2) It doesn't yet stop you from suggesting a read-only file system, but that's not really a problem
3) If you stop and restart, or if more programs are recorded during the first run, subsequent runs will only sweep up the files that haven't been saved - that's great when you're trying to run a backup and the other half is still trying to record.
4) You might end up with some partial files lying around if you break out of the program, something to worry about later, but (3) will sort you out as a failsafe.
5) Because the files are being decrypted, fancy features like thumbnails or programme info will not be stored - this is a script to rescue your recordings so that you can store them elsewhere or to put them back onto a replacement machine.
6) The script doesn't copy sidecar files (no point) or any other content (why bother, this script is aimed at decrypting stored content and that's only the recorded programmes, you have ftp for the rest)
As I type, my backup has 899 files left so I expect that it will be busy for the next day or so - any suggestions?
If it helps, here's what the most recent run looks like
My HDR-T2 has been on the fritz for a while now and several posts on the forum make me think that the hard drive is on the way out. Apart from the fact that we only bought the dratted thing in February, how do we go about rescuing the contents before it goes back for repair?
Well, the answer seems to be that we need:
1) Custom firmware
2) Auto-unprotect installed and running
3) An external hard drive with enough space that you can write to
4) A cunning script to save you lots of time
Assuming that you can sort steps 1-3, here's my first cut at step 4:
progbackup.sh
Code:
#!/bin/sh
echo "Humax HDR-T2 backup utility"
echo
echo "Decrypts and backs up your videos to a local drive of your choosing."
echo "Other content will not be encrypted and can therefore be transferred off separately."
echo "HD content will not be decrypted unless you have cleared the encryption flag,"
echo "so, the script will exit if 'auto-unprotect' is not running"
echo
IFS=$'\n' #You need this or the for loop gets confused by spaces
host='127.0.0.1' # Yay localhost works!
used=`df -m | sed 's/ */ /g' | grep /mnt/hd2 | cut -f 4 -d\ `
echo "Examining your local drive, you need up to $used MB for the backup"
echo "Attached drives have the following free space (MB):"
for freespace in `df -m | sed 's/ */ /g' | grep /media/drive | cut -f 5,7 -d\ `
do
echo "$freespace"
done
target=""
answer="N"
while [ "$answer" != "y" ]
do
result=""
while [ "$result" = "" ]
do
echo "Which drive do you want to back up to? (CTRL-C to abort)"
read target
result=`df -m | grep $target`
echo "You have selected $target"
if [ "$result" = "" ]; then
echo "That is not a valid drive"
fi
done
targetspace=`df -m | sed 's/ */ /g' | grep $target | cut -f 5 -d\ `
echo "$target has $targetspace MB free and you need up to $used MB"
echo "Do you want to use this drive? [y/N]"
read answer
done
echo "Backing up to $target"
# What if someone has plugged in an NTFS drive and it's mounted read only?
# Check for Fat32/ntfs or check for R/W, or both?
#You really don't want to run this if you have HD contect and you aren't running auto-unprotect
AP=`opkg list-installed | grep auto-unprotect`
if [ "$AP" = "" ]; then
echo "Auto-unprotect isn't running, you don't want to download encrypted HD files"
echo "Install Auto-unprotect and wait 2 hours before rerunning"
echo "If you do not wait 2 hours, you could lose access to some HD files"
exit
fi
#How many programmes are there to backup?
lines=`sqlite3 /mnt/hd2/dms_cds.db "select mediaID,folder from tblMedia" | grep -v '|(NULL)' | wc -l`
echo "There are $lines programmes to backup"
#Should we have a pause here to confirm the target destination and whether or not to proceed?
#For each of the recorded programmes...
for line in `sqlite3 /mnt/hd2/dms_cds.db "select mediaID,folder from tblMedia"`
do
sep=`expr index "$line" \|` #There is a '|' separator between the fields
mediaID="${line:0:$(($sep-1))}"
filename="${line:$sep}"
filename=${filename%.ts}
dir=`dirname $filename`
file=`basename $filename`
if [ "$filename" != "(NULL)" ]; then
echo "$lines files left"
echo "Processing \"$filename\", Media ID is $mediaID"
newdir="$target/$dir"
mkdir -p "$newdir"
cd "$newdir"
if [ ! -e "$file.mpg" ]; then
url="http://$host:9000/web/media/$mediaID.TS"
echo "Getting $url"
wget $url
mv "$mediaID.TS" "$file.mpg"
fi
lines=$(($lines-1))
fi
done
It's a half-baked script but it seems to be working fairly well at the moment. The key points are:
1) It'll help you to not shoot yourself in the foot when choosing a target backup drive, but it's still possible if you try hard enough (nothing is foolproof to a sufficiently talented fool)
2) It doesn't yet stop you from suggesting a read-only file system, but that's not really a problem
3) If you stop and restart, or if more programs are recorded during the first run, subsequent runs will only sweep up the files that haven't been saved - that's great when you're trying to run a backup and the other half is still trying to record.
4) You might end up with some partial files lying around if you break out of the program, something to worry about later, but (3) will sort you out as a failsafe.
5) Because the files are being decrypted, fancy features like thumbnails or programme info will not be stored - this is a script to rescue your recordings so that you can store them elsewhere or to put them back onto a replacement machine.
6) The script doesn't copy sidecar files (no point) or any other content (why bother, this script is aimed at decrypting stored content and that's only the recorded programmes, you have ftp for the rest)
As I type, my backup has 899 files left so I expect that it will be busy for the next day or so - any suggestions?
If it helps, here's what the most recent run looks like
Code:
humax# ./progbackup.sh
Humax HDR-T2 backup utility
Decrypts and backs up your videos to a local drive of your choosing.
Other content will not be encrypted and can therefore be transferred off separately.
HD content will not be decrypted unless you have cleared the encryption flag,
so, the script will exit if 'auto-unprotect' is not running
Examining your local drive, you need up to 738614 MB for the backup
Attached drives have the following free space (MB):
19 /media/drive2
9 /media/drive3
12 /media/drive4
0 /media/drive5
0 /media/drive6
0 /media/drive7
3 /media/drive8
1318102 /media/drive1
Which drive do you want to back up to? (CTRL-C to abort)
/media/drive1
You have selected /media/drive1
/media/drive1 has 1318102 MB free and you need up to 738614 MB
Do you want to use this drive? [y/N]
y
Backing up to /media/drive1
There are 920 programmes to backup
920 files left
Processing "My Video/BOB'S/Scrapheap Challenge/Scrapheap Challenge_20110626_1145", Media ID is 5
919 files left
Processing "My Video/BOB'S/Scrapheap Challenge/Scrapheap Challenge_20110626_0935", Media ID is 6
918 files left
Processing "My Video/BOB'S/Scrapheap Challenge/Scrapheap Challenge_20110626_1040", Media ID is 7
917 files left
Processing "My Video/BOB'S/Scrapheap Challenge/Scrapheap Challenge_20110626_1250", Media ID is 8
916 files left
Processing "My Video/BOB'S/Emergency Bikers/Emergency Bikers_20110602_2000", Media ID is 10
915 files left
Processing "My Video/BOB'S/Emergency Bikers/Emergency Bikers_20110519_1959", Media ID is 11
914 files left
Processing "My Video/BOB'S/Emergency Bikers/Emergency Bikers_20110609_2000", Media ID is 12
913 files left
Processing "My Video/BOB'S/Emergency Bikers/Emergency Bikers_20110526_2000", Media ID is 13
912 files left
Processing "My Video/BOB'S/Emergency Bikers/Emergency Bikers_20110616_2000", Media ID is 14
911 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110509_2000", Media ID is 16
910 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110530_2000", Media ID is 17
909 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110425_2000", Media ID is 18
908 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110516_2000", Media ID is 19
907 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110606_2000", Media ID is 20
Getting http://127.0.0.1:9000/web/media/20.TS
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)
wget: can't open '20.TS': File exists
906 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110611_1030", Media ID is 21
Getting http://127.0.0.1:9000/web/media/21.TS
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)
21.TS 100% |*******************************| 1427M 00:00:00 ETA
905 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110502_2000", Media ID is 22
Getting http://127.0.0.1:9000/web/media/22.TS
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)
22.TS 100% |*******************************| 1345M 00:00:00 ETA
904 files left
Processing "My Video/BOB'S/The Gadget Show/The Gadget Show_20110523_2000", Media ID is 23
Getting http://127.0.0.1:9000/web/media/23.TS
Connecting to 127.0.0.1:9000 (127.0.0.1:9000)
23.TS 100% |*******************************| 1359M 00:00:00 ETA
903 files left