Safe editing wrapper: temp file, diff, backup only if changed.
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
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.
mirro can handle most of your favourite $EDITOR's flags.
mirro foo +123 (to open foo at line 123)Everything for this tool on one page: options, behaviour notes, and copy-paste examples.
Default location:
~/.local/share/mirro/
Under sudo it becomes /root/.local/share/mirro/.
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
# ---------------------------------------------
Shows a git-like diff between a current file and one of its backups.
mirro --diff file file.orig.20251121T163121
Shows files in the current directory with mirro history, revision counts, and latest timestamp.
mirro --status
Pruning removes backups older than MIRRO_BACKUPS_LIFE days (default 30).
mirro --prune-backups
mirro --prune-backups=14
mirro --prune-backups=all
export MIRRO_BACKUPS_LIFE=7
Invalid/non-numeric values fall back to 30. A value of 0 is invalid.
mirro /etc/nginx/nginx.conf
mirro launches your $EDITOR against a temp file, then compares content on exit.
mirro --list
Shows permissions, owner/group, timestamps, and backup filenames.
mirro --restore-last ~/.config/myapp/config.ini
mirro --restore filename.ext.orig.20251110T174400
Restores the file contents (mirro header removed) to the original target.