Tumblr log mirror utility
Find a file
2025-07-02 20:18:23 +02:00
src Omit tags 2025-07-02 20:18:23 +02:00
.dockerignore Add container build 2025-01-31 11:24:45 +01:00
.env-example Extend .env example 2025-01-31 11:31:44 +01:00
.gitignore Initital version 2025-01-30 19:31:40 +01:00
backup.py Add container build 2025-01-31 11:24:45 +01:00
Containerfile Add container build 2025-01-31 11:24:45 +01:00
Containerfile.www Add correct README example 2025-01-31 11:49:28 +01:00
entrypoint.sh Add container build 2025-01-31 11:24:45 +01:00
LICENSE Add 0BSD license 2025-01-31 11:31:15 +01:00
README Add crontab example 2025-01-31 12:13:28 +01:00
requirements.txt Initital version 2025-01-30 19:31:40 +01:00

Once built, this container will download all posts from a Tumblr blog,
including the images embedded in each post.

The downloaded content is then used as input to a static site generator,
creating a simple static blog site to browse locally or host online.

Setup
-----

Obtain Tumblr credentials: consumer+secret, oauth token+secret. See
Tumblr API documentation.

Also, figure out the name of the blog to mirror.

Then, choose any option below.

Option 1: store local copy and add new posts incrementally
----------------------------------------------------------

This is suitable for keeping a local copy and adding new posts over time,
for example by a cron job.

* `TBS_LAST_SYNC` is a ISO-formatted datetime. All posts that are _earlier_
than the provided datetime will be skipped.

mkdir posts build media
podman build .
podman run --rm -it \
-e TBS_CONSUMER_KEY=<replace me> \
-e TBS_CONSUMER_SECRET=<replace me> \
-e TBS_OAUTH_SECRET=<replace me> \
-e TBS_OAUTH_TOKEN=<replace me> \
-e TBS_BLOG_NAME=<replace me> \
-e TBS_LAST_SYNC="2020-01-01 06:06" \
-v ./posts:/app/src/posts \
-v ./build:/app/src/images \
-v ./output:/app/site \
<container image id>

Mirror files are now available in `./build`, open
`build/index.html` in a web browser to view it.

Typical Caddy config:

```
mirror.example.com {
	root * /var/www/mirror.example.com
	encode gzip
	file_server
}
```

Typical crontab:

```
0 6 * * * $HOME/mirror.sh
```

mirror.sh:

```
#!/bin/bash
BLOG_NAME="your-blog-name"
yesterday=$(expr $(date -u +%s) - 86400)
podman run --rm -it \
-e TBS_CONSUMER_KEY=$TBS_CONSUMER_KEY \
-e TBS_CONSUMER_SECRET=$TBS_CONSUMER_SECRET \
-e TBS_OAUTH_TOKEN=$TBS_OAUTH_TOKEN \
-e TBS_OAUTH_SECRET=$TBS_OAUTH_SECRET \
-e TBS_BLOG_NAME=$BLOG_NAME \
-e TBS_LAST_SYNC=$yesterday \
-v ./posts:/app/src/posts \
-v ./build:/app/src/images \
-v ./output:/app/site \
<container image id>
```



Option 2: Make mirror and serve by httpd
----------------------------------------

This is suitable for resting/abandoned blogs. May be served behind a
reverse proxy like caddy.

podman build \
--build-arg CONSUMER_KEY=<replace me> \
--build-arg CONSUMER_SECRET=<replace me> \
--build-arg OAUTH_SECRET=<replace me> \
--build-arg OAUTH_TOKEN=<replace me> \
--build-arg BLOG_NAME=<replace me> \
-f Containerfile.www

podman run -p 8080:80 <container image id>

Mirror is now available at http://localhost:8080