Scripts for launching darktable with a config stored in a custom location. In my case, location is on an SSD and I have experienced my configuration getting corrupted when my computer halted. This prevents that by maintaining 5 sequential backups of the entire configuration.
Find a file
2026-06-10 23:20:36 -04:00
bin Updating readme and adding commentary 2026-06-10 23:20:36 -04:00
LICENSE Initial commit 2026-06-11 03:08:36 +00:00
README.md Updating readme and adding commentary 2026-06-10 23:20:36 -04:00

darktable-launch

Two small bash scripts for keeping your darktable configuration safe when it lives on an external SSD.

Background

darktable stores its entire configuration — preferences, styles, presets, history, and the SQLite library database — in a single config directory. If that directory lives on an SSD and the drive doesn't eject cleanly (e.g. after a sudden shutdown), the database can be corrupted and difficult to recover.

These scripts address that by:

  1. darktable-launch.sh — takes a rotating snapshot of the config to your internal drive every time you open darktable, then launches darktable pointing at the SSD config. Up to MAX_BACKUPS snapshots are kept; the oldest is dropped each time.
  2. darktable-restore.sh — lets you pick one of those snapshots and restore it back to the SSD, in case something goes wrong.

The config path uses a ~/darktable symlink rather than a hard-coded mount point so the same scripts work across machines and operating systems (Linux auto-mounts SSDs to /run/media/…; macOS mounts them under /Volumes/…).


Prerequisites

  • bash
  • rsync
  • darktable on your PATH
  • notify-send (Linux, optional — used for desktop notifications on failure)

Setup

1. Mount your SSD

Linux

Find the device name:

lsblk
# or
blkid

Create a persistent mount point and mount the drive:

sudo mkdir -p /mnt/ssd
sudo mount /dev/sdX1 /mnt/ssd   # replace sdX1 with your actual device

To mount automatically on boot, add a line to /etc/fstab. First get the UUID:

sudo blkid /dev/sdX1

Then append to /etc/fstab (replace placeholders):

UUID=your-uuid-here  /mnt/ssd  exfat  defaults,nofail  0  0

The nofail option means the system still boots normally when the SSD is absent.

macOS

macOS mounts external drives automatically under /Volumes/<drive-name> when plugged in. No manual mounting is required.


Point ~/darktable at whatever directory on the SSD holds your darktable data. The scripts expect darktable-config to live inside this directory.

Linux (adjust the mount path to match your setup):

ln -s /mnt/ssd ~/darktable

macOS (adjust the volume name to match your drive):

ln -s "/Volumes/MySSD" ~/darktable

Verify the symlink resolves correctly:

ls ~/darktable/darktable-config

If you see your darktable config files, the symlink is working.


3. Create the backup directory

The backup destination on your internal drive must exist before the first run:

mkdir -p /mnt/extra/darktablebak   # or wherever you set BACKUPBASE

4. Configure the scripts

Open bin/darktable-launch.sh and bin/darktable-restore.sh and set the variables at the top of each file:

Variable Description Default
CONFIGDIR Full path to the darktable config folder on the SSD /home/andrew/darktable/darktable-config
BACKUPBASE Directory on your internal drive where backups are stored /mnt/extra/darktablebak
MAX_BACKUPS Number of rolling snapshots to keep (launch script only) 5

Both scripts use the same CONFIGDIR and BACKUPBASE values — keep them in sync.


5. Make the scripts executable

chmod +x bin/darktable-launch.sh bin/darktable-restore.sh

Usage

Launching darktable

Run darktable-launch.sh instead of darktable directly:

/path/to/bin/darktable-launch.sh

What it does:

  • Checks that CONFIGDIR exists (aborts if the SSD isn't mounted).
  • If BACKUPBASE is reachable, rotates existing backups (backup.2backup.3, etc.) and writes a fresh backup.1. Each snapshot includes a .backup-timestamp file.
  • If the backup drive is absent, logs a warning and launches darktable anyway — the SSD config is still used.
  • Launches darktable with --configdir pointing at the SSD config.

Tip: wire this up as your desktop launcher so the backup happens automatically every time you open darktable (see below).

Restoring a backup

Run darktable-restore.sh while darktable is closed:

/path/to/bin/darktable-restore.sh

The script will:

  1. Refuse to run if darktable is open.
  2. List all available backups with their timestamps.
  3. Ask which backup to restore.
  4. Ask for confirmation before overwriting the live config.
  5. Restore the chosen snapshot with rsync.

Wiring up the launcher (Linux desktop)

As a .desktop file

Create ~/.local/share/applications/darktable-launch.desktop:

[Desktop Entry]
Name=darktable
Comment=Launch darktable with config backup
Exec=/path/to/bin/darktable-launch.sh
Icon=darktable
Terminal=false
Type=Application
Categories=Graphics;Photography;

Replace /path/to/bin/darktable-launch.sh with the absolute path. After saving, the entry will appear in your application launcher.

As a shell alias

# in ~/.bashrc or ~/.zshrc
alias darktable='/path/to/bin/darktable-launch.sh'

Backup layout

BACKUPBASE/
├── backup.1/          ← most recent (written on last launch)
│   ├── .backup-timestamp
│   └── … config files …
├── backup.2/
├── backup.3/
├── backup.4/
└── backup.5/          ← oldest (dropped on next launch)

Backups are full copies (via rsync -a --delete), not incremental, so each one is independently restorable without any of the others.