Skip to content

Instantly share code, notes, and snippets.

@jeff47
jeff47 / Resizing a disk image (shrink).md
Created September 28, 2025 00:41
Resizing a disk image (shrink)

Purpose: Create a flashable image of a drive and resize it so unused space is minimized. Created image can be flashed as a backup that contains all config files.

Application: Backups of router and pihole.


Before starting, make sure the disk to be imaged is unmounted.

  1. Image the source drive: sudo dd if=/dev/sdb of=image.img bs=4M status=progress If space is an issue, dd can be piped straight to gzip, but you'll need to unzip before you can manipulate the image. sudo dd if=/dev/sdb bs=4M status=progress | gzip -9 > image.img.gz
@jeff47
jeff47 / Automate pihole backups with teleporter.md
Created September 8, 2025 12:37
Automate pihole backups with teleporter

In Pihole v6+, the teleporter commandline interface moved to pihole-FTL. It outputs to a zip file in the current directory, which needs to be dealt with if you are running this in a docker container.

I run two piholes: one for my general network, and a special one for kids.

In your docker-compose.yml, add a volumes line mapping the directory on the host you want to store the teleporter files to the directory /teleporter in the docker container. In my case, those are ./pihole-teleporter/ and ./kidspi-teleporter/, off my home directory. Edit the script if you want to move them or rename them.

#!/bin/bash

DOCKER_FILE="${HOME}/docker-compose.yml"
@jeff47
jeff47 / Raspberry Pi Docker + macvlan Restoration Workflow.md
Created September 8, 2025 12:36
Raspberry Pi Docker + macvlan Restoration Workflow

Raspberry Pi Docker + macvlan Restoration Workflow

1. Install required packages

sudo apt update
sudo apt install -y docker.io docker-compose network-manager dnsutils
sudo systemctl enable docker NetworkManager
sudo systemctl start docker NetworkManager
@jeff47
jeff47 / Snapraid-btrfs.md
Created September 7, 2025 00:35
Snapraid-btrfs

SnapRAID-BTRFS

Background

This guide builds on the Perfect Media Server setup by using BTRFS for data drives and taking advantage of snapraid-btrfs to manage SnapRAID operations using read-only BTRFS snapshots where possible. One of the main limitations of SnapRAID is that there is a dependence on live data being continuously accessible and unchanging not only for complete parity sync purposes, but also for complete recovery in the event that a drive needs to be rebuilt from parity.

Note:
Recent updates in Snapper v0.11+ broke the snapraid-btrfs script by automorphism88. Use this patched version by D34DC3N73R until anamorphism88's version is fixed.

Using snapraid-btrfs, there is no requirement to stop any services or ensure that the live filesystem is free of any new files or changes to existing files.

@jeff47
jeff47 / Wildcard domains in pihole.md
Created September 7, 2025 00:33
Wildcard domains in pihole

It can be useful to create wildcard domains for local services.  Rather than create one for each local service, a wildcard is easier. It would be easy to use dnsmasq to do this, but Pihole no longer directly supports that.

There are two options to get this to work:

misc.dnsmasq_lines

The developers of Pihole anticipated that we might have this very need. In the GUI, switch to Expert mode and then go to All Settings->Miscellaneous. Scroll down to misc.dnsmasq_lines where you can add individual values that will be injected into the configuration.

Add address=/.local.mydomain.com/192.168.1.16 for a wildcard. (The leading . is vital!)

Regex domain redirects

@jeff47
jeff47 / split_mp3.py
Created October 2, 2024 21:36
Split audiofiles from Sony ICD-UX570 using timestamp (TMK) file
import re, subprocess, sys
audiofile = sys.argv[1]
basename = sys.argv[1].split('.')[0]
timestamp_file = basename + ".tmk"
timestamps = []
with open(timestamp_file, 'r') as file:
for line in file:
@jeff47
jeff47 / docker-openvpn-torrent.md
Last active July 16, 2020 15:10
Using docker to provide OpenVPN networking to other containers

Docker: Using an OpenVPN container to protect torrent

Overview

There are a number of docker containers that bundle VPN software with different torrent software (such as these projects for Transmission or rTorrent). You can certainly use those projects, but they don't follow the general Docker ethos of "one job per container". Additionally, some flexibility is lost by combining packages like this. So here I'm doing to go over how to get the same functionality using different containers, working together.

OpenVPN