Max Wrenna

Backing up Bear Blog posts

In the bearblog settings there is an 'Export all blog data' which provides a csv dump of all posts and metadata, which is lovely, but I wanted a markdown file version with any images also backed up locally, because it's always the images that end up lost or broken!

So I put together a bash script to run on the csv that makes a local backup:

I haven't automated the csv download itself, I'm happy to just do this now and then by hand.

(change OUTDIR to where you want it to go. ~/Sync is backed up with syncthing for me, as well as being in my nightly backups)

#!/usr/bin/env bash
set -euo pipefail

CSV="$1"
OUTDIR=~/Sync/writing/bear-blog-backup-$(date +%Y-%m-%d)
mkdir -p "$OUTDIR"
cd "$OUTDIR"

# strip BOM, python convert to json
json=$(python3 -c 'import csv, json, sys; print(json.dumps(list(csv.DictReader(open(sys.argv[1])))))' "$CSV")

echo "$json" | jq -c '.[]' | while read -r row; do
	slug=$(echo "$row" | jq -r '.["canonical url"] // empty')
	[ -z "$slug" ] && slug=$(echo "$row" | jq -r '.slug')
	file="${slug}.md"
	[ "$file" = ".md" ] && file="unnamed-$(date +%s).md"
	echo "Backing up $file"

	{
		while IFS= read -r key; do
			val=$(echo "$row" | jq -c -r --arg k "$key" '.[$k]')
			[ "$val" = "" ] && continue
			clean_key=$(echo "$key" | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
			# flatten arrays
			if [[ $val == \[*\] ]]; then
				val=$(echo "$val" | jq -r '. | join(", ")')
			fi
			echo "${clean_key}: ${val}"
		done < <(echo "$row" | jq -r 'keys[]' | grep -v '^content$')

		echo
		echo '---'
		echo
		echo "$row" | jq -r '.content'
	} >"$file"

        sed -i 's/^\xEF\xBB\xBF//' "$file"

	# replace image URLs + download
	while read -r img; do
		url=$(echo "$img" | grep -oE 'https[^)]+')
		fname=$(basename "${url%%\?*}")
		sed -i "s|$url|./$fname|g" "$file"
		curl -sL "$url" -o "$fname"
	done < <(grep -oE '!\[[^]]*\]\(https[^)]+\)' "$file")
done

tar -czf "${OUTDIR}.tar.gz" -C "$(dirname "$OUTDIR")" "$(basename "$OUTDIR")"

echo "Backup complete: $OUTDIR.tar.gz"

And here is what is captures from this recent post)

all_tags: other
first_published_at: 2025-10-02T19:36:00+00:00
is_page: False
make_discoverable: True
meta_description: "But you like her ironically, right?"
publish: True
published_date: 2025-10-02T19:36:00+00:00
slug: taytay
title: Taylor Swift and the joy of liking things
uid: hdXSmQIbyUohKfrFfRYV

---

On the eve of Taylor's next album release, I am reminded how nice it is to like things. Something to look forward to! What fun. How delightful. No downsides.

Growing up I thought liking things was dangerous. It made me vulnerable to attack. It was safer to be cynical, to hedge all preferences with criticisms. Give myself some breathing room in case my opinion reflected badly on me. Certainly don't let someone see my bookshelf.

But a few years ago I listened to some Taylor Swift and liked it, and the extreme uncoolness of liking Taylor Swift meant there was no hedging to be done. It was either like her sincerely, or reject her fully.[^1]

![90,000 screaming fans](./tay.webp)

So I like her unapologetically. People try to give me an out sometimes, "but you like her ironically, right?" my boss once asked me. Nah. I just like her. "You like her physically, you mean?" Nah. I like her music.

I found myself leaning into it a little. Listening to her more and more. It is now a thing people know about me. Max likes Taylor Swift. Odd, but wholesome. A positive thing.

And I want to keep it that way. I don't want to be a fan. I don't read the discourse, I don't try to defend her on the internet. I'm a secular swifty. I won't be reading any reviews of the new album. I'm going to listen to it, and have my own opinions. Maybe listen to it again a few days later, maybe change my mind. Who knows.

I will enjoy it without considering what that means about me. And that is nice.

[^1]: (Also, I'm older now, and care less.)

#tech