ForumsTips & TricksAutomating Toodledo Backups


Automating Toodledo Backups
Author Message
tbaker

Posted: Apr 01, 2010
Score: 1 Reference
Hi all,
I had a weekly task on my task list that always seemed to slip by never getting done when it was supposed to. This task was possibly the most important one on my list. This task was downloading a copy of all my toodledo data for backup using the XML export function.

As all good IT folks will tell you, there's no backups until you have a backup off-site (and no, the copy of your tasks on Toodledo don't count). I thought since I've spent a good time customizing my backup routine, I'd share with you all how I achieve this.

First off, I don't want to take credit for the idea, I only added a few things to existing discussions and scripting found at and inspired by TheGriff found here >> https://www.toodledo.com/forums/3/2227/0/back-up-your-toodledo-data-with-wget.html

Secondly, this provided link has a user who implements this on linux as well. To be clear, this is a WINDOWS script.

Below I provide an listing of the steps the script takes, the dependancies on other applications, and steps needed to implement this to use yourself.

Script Overview - Steps
==========================
1) Starts a log file that will be emailed.
2) Downloads the XML file from toodledo
3) Compresses it, naming the file with the date (I get about 14/1 compression with this, going from a file that is natively 1.65Mb down to 245kb)
4) Moves the file to a safe offsite Location, in a nice tiered folder structure. \Year\Month\Day (\2010\04\01\)
5) Emails me notice that this process completed.

Dependancies
================================================
WGet - Used for downloading the XML file from toodledo
- WGet is a command line utility.
- WGet can be downloaded from http://gnuwin32.sourceforge.net/packages/wget.htm


7-zip - 7Zip is a great compression and archive utility. It can be run with parameters at the command line
- 7-zip can be downloaded from http://www.7-zip.org/


Blat - Used for emailing the log file
- Blat is a great command line utility that can take the contents of a text file and email it via your own defined email server.
- Blat has good documentation on how to set up a profile and how to send email if you're interested by running "blat /?" from the command line.
- Blat can be downloaded from http://www.blat.net/


Stunnel - Provides SSL connection (where necessary) to send email.
- Since my email address (and thus server) of choice is hosted with Google apps, I need to wrap the Blat email communicatoins with SSL. Google only allows users who can authenticate (which blat does natively) and encrypts the communications (which blat does not do).
- Configuring Stunnel is the worst part of this whole setup.
- If your email server requires SSL, I suggest you consult your favorite IT person for help getting this setup, it's no fun. If you are using google apps, or gmail, let me know, I'll send you the config I ended up using.
- STunnel can be downloaded from http://www.stunnel.org/

Jungle Disk - Software that allows use of Amazon S3 as a disk Drive.
- In my actual script, I'm copying this data right offsite to my Jungledisk Drive.
- Any Online backup solution would be appropriate here, my favorite is Jungle Disk
- This step can also be used to store files locally.
- Jungle Disk can be purchased from http://www.jungledisk.com

Configuring Dependancies
================================================
- I run this script from c:\bin, If you decide to run this script from a different lcoation, it will have to be updated as the log file used is referenced by it's defined location.
- Blat is configured in my script to use a profile named "tbakerwebgmail", this stores my username, password, and email server settings defined. See Blat's documentation for how to configure a blat profile.
- Blat, 7zip and WGet's folders are expected to be in the "Path". if you don't understand what this means, again, consult your favorite IT person.

Customizing the Script for your use
================================================
I've placed the following strings in the file. they need to be replaced with your appropriate information
- Line 23 - toodledoEmailAddress - The Email Address you subscribe to Toodledo with
- Line 23 - toodledoPassword - Your Password for Toodledo
- Line 39,40 - backupRootPath - This is your local filesystem location where you want the Year\Month\Day folders to be created.
- Line 47 - blatProfileName - This is the Blat Profile name to use.
- Line 47 - toEmailAddress - This is the email address you want the notice of backup completion to be sent to.

Once you've configured the script to use your specfic settings, you'll want to add this to your windows Task scheduler.

Copy everything below this line into a text file and save it as c:\bin\toodledo_backup.bat
================================================
@Echo Off
@For /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do @(
Set Day=%%C
Set Month=%%B
Set Year=%%D
)

@For /F "tokens=1,2,3 delims=: " %%E in ('time /t') do @(
Set Hour=%%E
Set Minute=%%F
Set AMPM=%%G
)
Set Longdate=%Year%-%Month%-%Day%-%Hour%-%Minute%-%AMPM%

date /T > c:\bin\logs\current-toodledo.log
time /T >> c:\bin\logs\current-toodledo.log

echo Toodledo Backup Starting... > c:\bin\logs\current-toodedo.log


echo. >> c:\bin\logs\current-toodledo.log
echo Fetching XML... >> c:\bin\logs\current-toodledo.log
wget --no-check-certificate --save-cookies cookies.txt --post-data "email=toodledoEmailAddress&pass=toodledoPassword" https://www.toodledo.com/signin.php
wget --load-cookies cookies.txt http://www.toodledo.com/xml.php

del index.php
del cookies.txt
move xml.php toodledo.xml

echo. >> c:\bin\logs\current-toodledo.log
echo Compressing XML... >> c:\bin\logs\current-toodledo.log
7z a -mx3 -tzip toodledo_%Longdate%.zip toodledo.xml

del toodledo.xml

echo. >> c:\bin\logs\current-toodledo.log
echo Moving to Jungledisk Drive... >> c:\bin\logs\current-toodledo.log
mkdir "backupRootPath\%Year%\%Month%\%Day%"
move toodledo_%Longdate%.zip "backupRootFolder\%Year%\%Month%\%Day%\toodledo_%Longdate%.zip"

echo. >> c:\bin\logs\current-toodledo.log
echo File uploaded as toodledo_%Longdate%.zip >> c:\bin\logs\current-toodledo.log

echo. >> c:\bin\logs\current-toodledo.log
echo Backup Complete! >> c:\bin\logs\current-toodledo.log

blat c:\bin\logs\current-toodledo.log -p blatProfileName -to toEmailAddress -subject "Toodledo Backup Completed"


This message was edited Apr 01, 2010.
You cannot reply yet

U Back to topic home

R Post a reply

To participate in these forums, you must be signed in.