
π€ When a Backup Fails… Because of a Filename
Recently, one of my automated backups on Linux unexpectedly crashed mid-run. No fancy error message, no graceful fallback β just a silent abort.
After some hardcore grep and log spelunking, I found the culprit: a single file with a non-compliant filename that the backup tool couldnβt process. Worse yet β the file had come from a macOS system (MacBook Air). Of course. π
Turns out macOS loves to sprinkle in some lovely Unicode quirks, invisible characters, and creative use of special symbols. Great for humans, not so great for Linux file systems or backup tools.
πΎ Enter rdiff-backup: My Versioned Backup Weapon of Choice
I use rdiff-backup for my daily backups because it supports versioned, incremental backups β like Time Machine, but nerdier and CLI-friendly:
rdiff-backup /data /mnt/backup/dataBut hereβs the kicker: rdiff-backup choked on that malformed filename and bailed out. No incremental magic, no versioning β just failure.
Lesson learned: Clean your files before backing them up. So I added a pre-backup step: detox.
π§Ό What Is detox and Why Should You Care?
detox is a small Linux command-line tool that recursively cleans up messy filenames by removing problematic characters like:
- Spaces
- Umlauts (Γ€, ΓΆ, ΓΌ β ae, oe, ue)
- Unicode madness
- Weird symbols and control characters
Perfect for files that came from… well… anywhere that isn’t Linux.
π οΈ Install It
On most distros, itβs as simple as:
sudo apt install detoxπ Basic Usage
To recursively clean a directory:
detox -r /your/directoryπ§ Sample Before/After Magic
| Original Filename | Cleaned Up |
|---|---|
| Urlaubsfotos 2024 (KΓΆln).jpg | Urlaubsfotos_2024_Koeln.jpg |
| RΓ©sumΓ©_finalΓ©.pdf | Resume_finale.pdf |
| Projekt 1#Beta!.zip | Projekt_1Beta.zip |
π§ͺ Recommended Schemes
detox supports various “schemes” for how filenames are sanitized. Here’s what worked best for me:
detox -r -s utf_8 -s iso8859_1 -v /datautf_8: removes funky multibyte Unicode stuffiso8859_1: transliterates German/French accents-v: shows exactly whatβs being renamed (highly recommended)
π Now My Backup Pipeline Looks Like This
# Step 1: Clean up file names
detox -r -s utf_8 -s iso8859_1 -v /data
# Step 2: Run versioned backup
rdiff-backup /data /mnt/backup/data
Ever since I added detox to the mix, my rdiff-backup runs have been smooth as butter β even when syncing messy files from macOS, USB sticks, or synced cloud folders.
π§ Automate It Like a Nerd
If you’re into scripting, here’s a no-nonsense example:
#!/bin/bash
SOURCE="/data"
TARGET="/mnt/backup/data"
# Clean first
detox -r -s utf_8 -s iso8859_1 -v "$SOURCE"
# Then backup with version history
rdiff-backup "$SOURCE" "$TARGET"
Add it to cron, systemd, or whatever your flavor of automation is. Youβll thank yourself later.
π Final Thoughts
If you’re running backups, syncing across OSes, or just want filenames that won’t make your shell scripts cry, detox is a must-have.
Itβs small, fast, recursive, and it saved my ass. Especially when used with rdiff-backup, it makes your backup pipeline a lot more resilient and deterministic.
And remember: garbage in, garbage out. Clean first, backup second.







