Backup script for ToodleDo

 

Just started using ToodleDo with the GotToDo Android app on my HTC Desire.

There is a rare bug in the app which has deleted all the ToodleDo tasks for a very small number of people. the author of the app is working on a solution at the moment, but in retrospect I should have had a backup plan for this data anyway.

Benny Morrison on the app mailing list sent me a DOS script he used to back up his Toodledo account, and I have hacked it to work under linux (the core functionality comes from Benny – all I did was wrap it up in some linux specific stuff to create the appropriate directories and do some rudimentary checking).

The (short) script is below. I run this from a cron job a few times a day.

Pete

NOTE: script updated 26th July 2011 after ToodleDo redesign

#!/bin/sh
# Script to backup toodledo account
# makes a backup on your local machine and
# sends a copy to a google account of your choice
## CONFIGURATION SECTION
## CHANGE THESE VARIABLES ONLY
#
# Where you want the data stored.
DATADIR=/home/YOUR-NAME-HERE/toodledo-backup/$(date +%Y)/$(date +%m)/$(date +%d)/$(date +%H:%M:%S)
LOGIN="TOODLEDO-LOGIN"
PASS="TOODLEDO-PASSWORD"
# This variable is where you want copies of the backups sent. I use a dedicated gmail account.
ARCHIVEMAIL=ARCHIVE-EMAIL-ADDRESS
#
## END OF CONFIGURATION SECTION
mkdir -p $DATADIR
cd $DATADIR
wget -q --no-check-certificate --keep-session-cookies --save-cookies cookies.txt --post-data "email=$LOGIN&pass=$PASS" https://www.toodledo.com/signin.php
wget --quiet -O Tasks.xml --load-cookies cookies.txt http://www.toodledo.com/tools/xml.php
rm cookies.txt
rm index.php
#
## Check for login errors
if [ -f signin.php ]
then
echo "$0 - ERROR - login not complete.
There is a HIGH RISK that your ToodleDo backup did not complete."
fi
#
## Does the Tasks.xml file look OK ?
if ! egrep -q '' Tasks.xml
then
echo "$0 - ERROR - Problem with Tasks.xml file.
There is a HIGH RISK that your ToodleDo backup did not complete."
fi
## Now mail the file to a google account
/usr/bin/mutt -s "ToodleDo backup - `/bin/date`" -a Tasks.xml -- $ARCHIVEMAIL < /dev/null

5 Responses to “Backup script for ToodleDo”


  • Good stuff. Looks like you wrapped it up nicely. Glad I could help. GotToDo and ToodleDo are a powerful combination and there are other features coming that will make people very happy.

  • Hi – is it possible to alter this script so that it prompts for a password instead of storing it as plain text…? If so, please can you post the changes. Thanks!

  • IMPORTANT: toodledo changed the location of their php files today with the redesign.

    Just add /tools before xml.php

    http://www.toodledo.com/tools/xml.php

    I have modified the main post to reflect this.

    Pete

  • Hi Derek. Not tried to do this yet. My initial thought is that you need to have a look at the wget command line.

  • If you add the “remember” option that’s bind to the checkbox from the signin page you can remember the login credential via a cookie.

    The script can ask the password from the command line in a first “init” phase

    This method avoid storing the pass in the file or in the command line

    #!/bin/sh
    # Script to backup toodledo account
    # makes a backup on your local machine and
    # sends a copy to a google account of your choice
    ## CONFIGURATION SECTION
    ## CHANGE THESE VARIABLES ONLY
    #
    # Where you want the data stored.
    rcookie=”.toodledo-remember.cookie”
    scookie=”.toodledo-session.cookie”
    OUT=$(pwd)
    init=”false”
    while [ $# -gt 0 ]
    do
    case “$1″ in
    -init) init=”true” ; shift 1 ;;
    -out) OUT=” $2″; shift 2 ;;
    esac
    done
    [ ! -w $OUT ] && echo “Impossible d’écrire dans $OUT” && exit 1
    cd $OUT
    [ ! -e $rcookie ] && init=”true” && echo “Cookie absent”
    if [[ "$init" == "true" ]]; then
    [ -e $rcookie ] && rm $rcookie
    read -p “Enter Login: ” LOGIN
    read -s -p “Enter Password: ” PASS
    wget -q –no-check-certificate –keep-session-cookies –save-cookies ${rcookie} –post-data “email=$LOGIN&pass=$PASS&remember=on” https://www.toodledo.com/signin.php
    rm index.php
    else
    wget -q –no-check-certificate –keep-session-cookies –save-cookies ${scookie} –load-cookies ${rcookie} https://www.toodledo.com/signin.php
    sleep 3
    rm index.php
    wget –quiet -O Tasks.xml –load-cookies ${scookie} https://www.toodledo.com/tools/backup.php
    rm ${scookie}
    #
    ## Does the Tasks.xml file look OK ?
    if ! egrep -q ‘Toodledo :: XML Backup’ Tasks.xml
    then
    echo “$0 – ERROR – Problem with Tasks.xml file.
    There is a HIGH RISK that your ToodleDo backup did not complete.”
    exit 1
    fi
    fi

Leave a Reply




Switch to our mobile site