Backing up delicious bookmarks via curl and the command line

posted on 10 Oct 2009 - delicious

Hey, remember when Magnolia blew up?  Man, that was sure was fun for the whole family.

(OK, not really.)

But if you don’t have off-line backups of your on-line bookmarks, maybe you should do that – like, right now.

I use delicious, and have a few thousand bookmarks tagged and saved.  If something happened to delicious like what happened to Magnolia, I’d be a bit bummed out.

I don’t have to worry about that, however, and neither do you – if you have a delicious account, a Linux box and use the command line, you can set your system up to create backups whenever you want to.

You’ll need curl installed on your system to get this to work.  If you would also like the backup notifications emailed to you, a mail transfer agent will be required, too.

1.  Go to your home directory and create a directory to store the backups in.  For this example, we’ll use /home/zendo/ as the home directory.

cd /home/zendo
mkdir delicious.backup

2.  Verify that curl works for you with delicious when requesting a backup of all your bookmarks via their delicious API.

curl –user <your delicious username>:<your delicious passwd> -o \
/home/zendo/delicious.backups/backup.TEST.xml -O \
‘https://api.del.icio.us/v1/posts/all’ >/dev/null 2>&1

If this works, you should be able to see all of your bookmarks in XML format in the file called backup.TEST.xml.

If this doesn’t work, there is always the possibility that your passwd isn’t correct… or maybe really bad sunspots are causing computer problems today.  You never know.

3.  Create the delicious backup script in a file, to run via the CLI.

joe /home/zendo/delicious.backups/delicious_backup.sh

Here is the curl-based delicious backup script I use for backing up my bookmarks to a local directory on my desktop machine.

Be sure to update the following information in the script, please!

SAVETO_DIR=<path to directory for bookmark backup storage>

DELICIOUS_USERNAME=<username>

DELICIOUS_PW=<password>

NOTIFICATION_EMAIL=<your email address>

4.  Run the script and see if it connects to the delicious API this time by checking your email for an update.

. /home/zendo/delicious.backups/delicious_backup.sh

You should get a mail titled, “Database Backup Status” with the contents saying, “Success at retrieving delicious.backup_(whatever date it is).xml.  Yay!

As usual, a final caveat:  this backup script could (should!) probably be implemented better using other methods for safety, speed, etc… however, it works for me.

If you want to learn more about how to backup your delicious bookmarks, or just find out a bit more about the API, you can do so by starting at these links and branching out from there:

The delicious web interface to back up bookmarks manually

The Firefox add-on for delicious

Using delicious API and python

Using the delicious API (from 2008, but still useful)