Tool

mirro

Safe editing wrapper: temp file, diff, backup only if changed.

Safety boundaries
  • Never edits the real file directly (edits a temp copy)
  • Backs up only when content changes
  • Restore strips the mirro header before writing back
  • Requires sudo only when actually needed; no auto-escalation
mirro logo

Quickstart

mirro /etc/nginx/nginx.conf
mirro --list
mirro --diff nginx.conf nginx.conf.orig.20251121T163121
mirro --restore-last ~/.config/myapp/config.ini
mirro --restore filename.ext.orig.20251110T174400
mirro --prune-backups           # uses MIRRO_BACKUPS_LIFE (default 30)
mirro --status
Tip: every page has copy buttons on code blocks.

Key features

Temp-file editing
Edit a safe temporary copy using $EDITOR.
Smart backups
Creates timestamped backups only when changed.
Built-in diff
Compare current file to any backup.

How it works

Step 1
Read & stage
Copy original content to a temp file (or stub new files).
Step 2
Edit
Launch $EDITOR (and accept many editor flags).
Step 3
Compare & commit
If changed, back up original then write new content.

Backup location & naming

Backups live in ~/.local/share/mirro/ (or /root/.local/share/mirro/ under sudo) and look like:

filename.ext.orig.20251110T174400

Each backup includes a header with the original path and timestamp.

TIP: mirro can handle most of your favourite $EDITOR's flags.
e.g. mirro foo +123 (to open foo at line 123)

Reference & examples

Everything for this tool on one page: options, behaviour notes, and copy-paste examples.

Backups & naming

Backup directory

Default location:

~/.local/share/mirro/

Under sudo it becomes /root/.local/share/mirro/.

Naming scheme

filename.ext.orig.20251110T174400

Timestamp is UTC-style compact format.

Backups include an origin header so you never lose track of where they came from.

# ---------------------------------------------
# mirro backup
# Original file: /path/to/whatever.conf
# Timestamp: 2025-11-10 17:44:00 UTC
# ---------------------------------------------

Diff & status

Built-in diff

Shows a git-like diff between a current file and one of its backups.

mirro --diff file file.orig.20251121T163121

Directory history status

Shows files in the current directory with mirro history, revision counts, and latest timestamp.

mirro --status

Pruning backups

Default prune behavior

Pruning removes backups older than MIRRO_BACKUPS_LIFE days (default 30).

mirro --prune-backups

Prune older than N days

mirro --prune-backups=14

Delete all backups

mirro --prune-backups=all

Environment variable

export MIRRO_BACKUPS_LIFE=7

Invalid/non-numeric values fall back to 30. A value of 0 is invalid.

Usage & flags

Edit a file

mirro /etc/nginx/nginx.conf

mirro launches your $EDITOR against a temp file, then compares content on exit.

List backups

mirro --list

Shows permissions, owner/group, timestamps, and backup filenames.

Restore backups

Restore most recent

mirro --restore-last ~/.config/myapp/config.ini

Restore a specific backup

mirro --restore filename.ext.orig.20251110T174400

Restores the file contents (mirro header removed) to the original target.