This document provides comprehensive information about LocalizationManager's backup and versioning system.
- Overview
- Key Features
- How It Works
- Backup Commands
- Backup Rotation Policy
- TUI Integration
- Best Practices
LocalizationManager includes a comprehensive backup and versioning system that automatically creates backups before modifying resource files. The system supports:
- Automatic backups for all destructive operations
- Version history with smart rotation policies
- Diff comparison between any two versions
- Selective restoration of specific keys or full files
- Metadata tracking (timestamps, operations, user info)
All backups are stored in .lrm/backups/ with a manifest file tracking version history.
Every command that modifies resource files (update, delete, import, translate, etc.) automatically creates a backup before making changes.
Each backup is assigned an incremental version number (v001, v002, etc.) and includes:
- Timestamp of creation
- Operation that triggered the backup
- User who created it
- Number of keys and changes
- SHA256 hash for integrity
The backup system automatically keeps up to 10 recent backup versions per file. Older backups are automatically pruned to save disk space.
Compare any two backup versions or compare a backup with the current state to see:
- Added keys
- Modified keys (with before/after values)
- Deleted keys
- Comment changes
Restore entire files or just specific keys from any backup version, with preview before applying changes.
Backups are automatically created before any destructive operation:
# These commands automatically create backups:
lrm update Key1 "New Value" # Creates backup before update
lrm delete Key2 # Creates backup before deletion
lrm remove-lang de # Creates backup before removing language
lrm import translations.csv # Creates backup before import
lrm translate --to fr --provider google # Creates backup before translation
lrm merge-duplicates --auto # Creates backup before merging
# This command does NOT create backups (creates new file):
lrm add-lang fr # No backup (creates new file)The backup is created before the operation, so you can always revert to the previous state.
Backups are stored in the .lrm/backups/ directory with the following structure:
YourProject/
├── Resources/
│ ├── Resources.resx
│ ├── Resources.el.resx
│ └── Resources.fr.resx
└── .lrm/
└── backups/
├── Resources.resx/
│ ├── manifest.json # Version history metadata
│ ├── v001_2025-01-15T10-30-45.resx # First backup
│ ├── v002_2025-01-15T11-15-22.resx # Second backup
│ └── v003_2025-01-15T14-22-10.resx # Latest backup
├── Resources.el.resx/
│ ├── manifest.json
│ ├── v001_2025-01-15T10-31-00.resx
│ └── v002_2025-01-15T14-22-15.resx
└── Resources.fr.resx/
├── manifest.json
└── v001_2025-01-15T14-22-20.resx
Important: Add .lrm/ to your .gitignore to avoid committing backups to version control.
Versions are numbered sequentially starting from 1:
v001- First backupv002- Second backupv003- Third backup, etc.
Version numbers are independent per file. Deleting backups does not renumber existing versions.
Display all backup versions for a resource file:
# List backups for default resource file
lrm backup list
# List backups for a specific file
lrm backup list --file Resources.el.resx
# Show detailed information (includes operation, user, changes)
lrm backup list --detailedExample output:
Backup History: Resources.resx
┌─────────┬──────────────────────┬────────────────┬──────────────┬──────┬─────────┐
│ Version │ Timestamp │ Operation │ User │ Keys │ Changed │
├─────────┼──────────────────────┼────────────────┼──────────────┼──────┼─────────┤
│ v003 │ 2025-01-15 14:22:10 │ delete │ john │ 150 │ -1 │
│ v002 │ 2025-01-15 11:15:22 │ update │ john │ 151 │ 2 │
│ v001 │ 2025-01-15 10:30:45 │ import │ john │ 149 │ 149 │
└─────────┴──────────────────────┴────────────────┴──────────────┴──────┴─────────┘
Total: 3 backups
Manually create a backup (useful before making manual edits):
# Create backup with default operation label ("manual")
lrm backup create
# Create backup with custom operation label
lrm backup create --operation "before-major-refactor"
# Create backup for specific file
lrm backup create --file Resources.fr.resxUse case: Run lrm backup create before editing .resx files in Visual Studio or other editors.
Restore a file from a backup version:
# Restore to version 2 (with preview)
lrm backup restore --version 2
# Restore specific file
lrm backup restore --version 2 --file Resources.el.resx
# Skip confirmation prompt
lrm backup restore --version 2 --yes
# Selective restore (only specific keys)
lrm backup restore --version 2 --keys Key1,Key2,Key3Safety features:
- Shows a preview of changes before restoring
- Creates a backup before applying the restore
- Validates the backup file integrity
- Confirms with the user unless
--yesis specified
Example workflow:
# 1. List available backups
lrm backup list
# 2. Preview what would change
lrm backup diff --version 2 --current
# 3. Restore the backup
lrm backup restore --version 2Compare two backup versions or a backup with the current file:
# Compare backup v2 with current state
lrm backup diff --version 2 --current
# Compare two backup versions
lrm backup diff --version-a 1 --version-b 3
# Show diff in JSON format (for scripts)
lrm backup diff --version 2 --current --output json
# Show diff in HTML format (for reports)
lrm backup diff --version 2 --current --output html > diff-report.html
# Include unchanged keys in output
lrm backup diff --version 2 --current --include-unchangedExample output:
Diff: v002 → Current (Resources.resx)
┌──────────┬──────────────┬─────────────────┬─────────────────┐
│ Key │ Type │ Old Value │ New Value │
├──────────┼──────────────┼─────────────────┼─────────────────┤
│ Key1 │ Modified │ "Old value" │ "New value" │
│ Key2 │ Deleted │ "Some value" │ │
│ Key3 │ Added │ │ "Added value" │
└──────────┴──────────────┴─────────────────┴─────────────────┘
Statistics:
Added: 1
Modified: 1
Deleted: 1
Total Changes: 3
Display detailed metadata for a specific backup version:
# Show info for version 2
lrm backup info --version 2
# Show info for specific file
lrm backup info --version 2 --file Resources.el.resxExample output:
Backup Information: Resources.resx v002
┌─────────────┬───────────────────────┐
│ Property │ Value │
├─────────────┼───────────────────────┤
│ Version │ v002 │
│ Timestamp │ 2025-01-15 11:15:22 │
│ Operation │ update │
│ User │ john │
│ Key Count │ 151 │
│ Changed │ 2 keys │
│ Hash │ a1b2c3d4... │
│ File Size │ 15.2 KB │
└─────────────┴───────────────────────┘
Remove old backups according to retention policy:
# Prune old backups (uses configured retention policy)
lrm backup prune
# Prune specific file
lrm backup prune --file Resources.el.resx
# Dry run (show what would be deleted)
lrm backup prune --dry-run
# Skip confirmation
lrm backup prune --yesSafety: Pruning will never delete all backups - at least one backup will always be preserved.
The backup system automatically keeps the most recent 10 backup versions per file. When a new backup is created and the limit is exceeded, the oldest backup version is automatically deleted.
- Maximum Versions: 10 backups per file
- Rotation: Automatic when limit exceeded
- Deletion: Oldest backup removed first (FIFO)
- Safety: At least one backup always preserved
Example:
Initial state: v001, v002, ..., v010 (10 backups)
New backup created → v011
Automatic cleanup → v001 deleted
Final state: v002, v003, ..., v011 (10 backups)
You can manually remove old backups using the prune command:
# Remove old backups while keeping recent ones
lrm backup prune
# Preview what would be deleted
lrm backup prune --dry-run
# Remove specific versions
lrm backup prune --version 5The interactive TUI (Terminal UI) includes a dedicated Backup Manager.
Press F7 in the main resource editor to open the Backup Manager.
- List View: Browse all backup versions with metadata
- Preview: See what changed in each version
- Diff Viewer: Compare any two versions side-by-side
- Restore: Restore selected version with preview
- Delete: Remove individual backups
- Prune: Clean up old backups with policy
| Key | Action |
|---|---|
| F7 | Open Backup Manager |
| ↑/↓ | Navigate backup list |
| Enter | View selected backup |
| D | Show diff with current |
| R | Restore selected backup |
| Del | Delete selected backup |
| P | Prune old backups |
| Esc | Close Backup Manager |
Backups are local and should not be committed to version control:
# Add to your .gitignore
.lrm/Before making significant manual edits, create a named backup:
lrm backup create --operation "before-v2.0-refactor"Always preview changes before restoring:
# 1. Check what changed
lrm backup diff --version 5 --current
# 2. If satisfied, restore
lrm backup restore --version 5If you accidentally modified a few keys, restore only those:
lrm backup restore --version 3 --keys ErrorMessage,WarningText,SuccessTextRun manual pruning periodically to free disk space:
# Check what would be pruned
lrm backup prune --dry-run
# Actually prune
lrm backup pruneFor critical snapshots, copy the backup file outside of .lrm/:
# Create a snapshot
lrm backup create --operation "release-v1.0.0"
# Copy to safe location
cp .lrm/backups/Resources.resx/v042_2025-01-15T10-30-45.resx \
../backups/release-v1.0.0-Resources.resxIf a backup isn't being created automatically:
-
Ensure you didn't use the
--no-backupflag:# Backups are created by default # Use --no-backup to skip them lrm update MyKey "value" --no-backup
-
Check disk space:
df -h . -
Check permissions:
ls -la .lrm/backups/
If restore fails:
-
Validate backup integrity:
lrm backup info --version <N>
-
Check file exists:
ls -la .lrm/backups/Resources.resx/
-
Try with
--yesto skip validation:lrm backup restore --version <N> --yes
If backups are taking too much space:
-
Check current usage:
du -sh .lrm/backups/
-
Prune old backups:
lrm backup prune
-
Delete specific old versions manually:
lrm backup prune --version 1 --version 2 --version 3
For more information, see: