Twitter Backup
The typical twitter backup service will ask you for your password, require additional registrations, store your data on some distant server, sell it to bad people or do some other annoying things.
This bash script allows you to download all your public musings by yourself. It's very ugly and it works.
#!/bin/bash
if [ -z "$1" ] then
echo 'twitter name:'
read twittername
else
twittername=$1
fi
if [ -z "$2" ] then
filename="$twittername.xml"
else
filename=$2
fi
temp=`mktemp temp.XXXXXX`
trap "rm $temp; exit 1" SIGINT SIGTERM
echo '<?xml version="1.0" encoding="UTF-8"?>' > $filename
echo '<statuses type="array">' >> $filename
for counter in {1..1024} do
url="http://twitter.com/statuses/user_timeline/$twittername.xml?page=$counter"
curl $url > $temp
if [ $(grep -c 'Rate limit exceeded' $temp) -eq 0 ] then
if [ $(grep -c '<status>' $temp) -ne 0 ] then
echo "appending page nr. $counter"
sed '1,2d;$d' $temp >> $filename
else
echo '</statuses>' >> $filename
break
fi
else
echo "Rate limit exceeded. Press return after waiting (ca. 1hr)."
read anykey
fi
done
rm $temp
Tipp: After downloading your (or someone else's) data you may want to transform the XML file into readable HTML using XSLT (or something similar).
Some space for comments is available here.