GitHub: suprepupre/WA-SafeGuard
WA_SafeGuard
Automatic backup and recovery for WeakAuras on WoW 3.3.5a (WotLK).
Protects your WeakAuras configuration from being permanently wiped when a forced disconnect corrupts WeakAuras.lua in SavedVariables.
Built for Warmane and other 3.3.5a private servers.
Table of Contents
- The Problem
- Why .bak Does Not Help
- The Solution
- Installation
- Commands
- How It Works
- Example Output
- FAQ
- File Structure
- Compatibility
- Contributing
- Acknowledgments
The Problem
If you run two WoW clients and log into the same account from the second client, the first client is forcefully disconnected. During shutdown, WoW attempts to write all addon data (SavedVariables) to disk:
Normal logout: 1. WoW serializes addon data 2. Renames old WeakAuras.lua -> WeakAuras.lua.bak 3. Creates new WeakAuras.lua 4. Writes all data to file 5. File closed, done Forced disconnect: 1. WoW serializes addon data 2. Renames old WeakAuras.lua -> WeakAuras.lua.bak 3. Creates new WeakAuras.lua 4. Starts writing data... CLIENT KILLED 5. WeakAuras.lua = 1 KB of garbage (truncated) WeakAuras.lua.bak = previous session's file
WeakAuras.lua often exceeds 5-30 MB, making it one of the largest SavedVariables files. The OS cannot flush that much data before the WoW process is terminated.
Result: All auras are permanently lost.
Why .bak Does Not Help
The common workaround is to delete the broken file and rename the .bak file. This fails in practice:
- WoW creates .bak by renaming the current WeakAuras.lua before writing the new one.
- If the current file was already corrupted from a previous force DC, the .bak becomes a copy of corrupted data.
- After two consecutive forced disconnects, both files are destroyed.
This is a cascading failure. Once the .bak mechanism is compromised, it cannot recover.
The Solution
WA_SafeGuard is a lightweight companion addon that:
- Stores a compressed backup of your WeakAuras data inside its own SavedVariables file.
- Automatically detects corruption on login and restores your SavedVariables from backup.
- Requires a single /reload after auto-restore to apply the data in-game.
Why this works
WoW writes SavedVariables files in alphabetical order:
WA_SafeGuard.lua ("WA_S...") -> written FIRST WeakAuras.lua ("Weak...") -> written SECOND
On a forced disconnect:
- WA_SafeGuard.lua (200-500 KB compressed) is fully written.
- WeakAuras.lua (5-30 MB) is interrupted.
The backup file is 3-5x smaller than the original due to:
- Cache stripping (removes auto-regenerated icon caches)
- Compact serialization (buffer-based writer, no whitespace)
- Huffman compression (via LibCompress, bundled with WeakAuras)
Small size + written first = survives the crash.
Installation
Manual Install
- Download the latest release or clone the repository.
- Extract or place the WA_SafeGuard folder into your WoW addons directory:WoW 3.3.5a/Interface/AddOns/WA_SafeGuard/
- Verify the structure:Interface/AddOns/WA_SafeGuard/ ├── WA_SafeGuard.toc ├── WA_SafeGuard.lua └── README.md
- Restart WoW or type /reload in-game.
- Ensure the addon is enabled on the character selection screen.
Important: Install this addon while your WeakAuras are working correctly. The first backup is created on login. If your auras are already lost, reimport them first, then /reload.
Commands
| Command | Description |
|---|---|
| /wastatus | Show current status: WA health, backup size, backup age |
| /wasave | Force an immediate backup of current auras |
| /warestore | Manually restore auras from the last good backup |
Automatic behavior
| Event | Action |
|---|---|
| Login (auras healthy) | Silently creates/updates backup |
| Login (auras corrupted) | Automatically overwrites SavedVariables with backup, prompts /reload |
| Zone change / Logout (clean) | Silently updates backup (via PLAYER_LEAVING_WORLD) |
| Zone change / Logout (auras corrupted) | Does nothing (preserves existing good backup) |
How It Works (Technical)
Flow diagram
┌─────────────────── LOGIN ─────────────────────────────────────────┐ │ Is WeakAurasSaved a valid table with a displays subtable? │ │ ├─ YES (healthy) │ │ │ -> Strip caches from copy of WeakAurasSaved │ │ │ -> Serialize into compact Lua string │ │ │ -> Compress with LibCompress (if available) │ │ │ -> Store in WA_SafeGuardDB.data │ │ └─ NO (corrupted / missing) │ │ -> Check if WA_SafeGuardDB.data exists │ │ ├─ YES -> Decode/Decompress/Deserialize -> Restore -> /reload │ │ └─ NO -> Prompt manual reimport │ ├─────────────────── LOGOUT ────────────────────────────────────────┤ │ Is WeakAurasSaved healthy? │ │ ├─ YES -> Silently update WA_SafeGuardDB │ │ └─ NO -> Do nothing │ └───────────────────────────────────────────────────────────────────┘
Serialization
The addon uses a custom buffer-based serializer. Unlike WoW's default SavedVariables writer, it produces compact, valid Lua strings without indentation or verbose key formatting.
Compression
If LibCompress is available, the serialized string is Huffman-compressed and encoded. If unavailable, the raw string is stored.
Corruption detection
Data is considered corrupted if:
- WeakAurasSaved is nil or not a table
- WeakAurasSaved.displays is not a table
- WeakAurasSaved.displays is empty while a valid backup exists
Safety measures
- Sandboxed deserialization via setfenv(fn, {})
- Size validation (>50 bytes) prevents treating empty backups as valid
- Never overwrites a good backup with corrupted data
- pcall wraps all serialization/compression operations
- 3-second login delay ensures all addons finish loading before backup runs
Example Output
Healthy login (backup created)
[SafeGuard] Loaded. Commands: /wastatus /wasave /warestore [SafeGuard] Backup OK 142 auras ~1847KB
Corrupted login (auto-restore)
[SafeGuard] Loaded. Commands: /wastatus /wasave /warestore [SafeGuard] == WeakAuras data is CORRUPTED! == [SafeGuard] RESTORED 142 auras! [SafeGuard] Auras restored to SavedVariables. Type /reload to apply.
Status check
/wastatus [SafeGuard] === Status === [SafeGuard] WeakAuras: OK (142 auras) [SafeGuard] Backup: OK 142 auras ~538KB 12 min ago
FAQ
Will this increase memory usage?
The compressed backup is typically 3-5x smaller than the original data. This is a negligible tradeoff for data integrity.
What if both files get corrupted?
Extremely unlikely due to alphabetical write order and smaller size. If it occurs, check WA_SafeGuard.lua.bak in your SavedVariables folder.
Does this work on other WoW versions?
Built and tested for 3.3.5a (WotLK). May work on 2.4.3 or 4.3.4 if ## Interface is updated, but is untested.
Can I use this without WeakAuras?
No. The addon only activates when WeakAuras data is present.
How do I prevent the issue entirely?
Before logging into a second client, type /reload on the first. This forces a clean save of all SavedVariables.
My auras are already gone. Can this recover them?
No. This addon prevents future loss. Reimport your auras, then /reload. The addon will protect them moving forward.
How often is the backup updated?
On every login and logout, provided WeakAuras data is healthy. Use /wasave after adding new auras mid-session.
File Structure
Addon files
WA_SafeGuard/ ├── WA_SafeGuard.toc ├── WA_SafeGuard.lua └── README.md
SavedVariables location
WTF/Account/<ACCOUNT_NAME>/SavedVariables/ ├── WA_SafeGuard.lua ├── WA_SafeGuard.lua.bak ├── WeakAuras.lua └── WeakAuras.lua.bak
Acknowledgments
- WeakAuras for WotLK
- The Warmane community for stress-testing this edge case.
Developed to solve a persistent WeakAuras data loss issue on private servers. MIT License.
Also for WoW 3.3.5a
| Project | What it does |
|---|---|
| wow_optimize | Engine-level optimization DLL - allocator, Lua VM, timers, file I/O, frame-time benchmark |
| LuaBoost | Addon-side GC control, loading-screen helpers, shared APIs for addon authors |
| DefileAlert | Instant Defile target callout for the Lich King encounter |



