Restore
Restore
Restore file to captured state
Every captured change carries its SHA-256-addressed content in BLOB_STORE. Restoring writes that content back to the original path — current file gets backed up to <path>.drift_restore_backup_<epoch> before overwrite.
What will change
Preview -- nothing has been written yet.
| Target file | /var/www/vhosts/3dshawn.com/site1/TEMPLATES/restore.html |
| Site | DriftSense self-monitor on local |
| Kind | local |
| Captured at | 2026-07-12 00:02:05 |
| Captured SHA | 10cf73c63f2d262a5669ad2dea63bd8f04522dd6b7601bbb11c80f32108848b4 |
Current state on disk
Live check just now. If SHAs match, the restore is a no-op.
| File present | yes |
| Size | 9250 bytes |
| Current SHA | 4bed1ca57f38 |
| Same as captured? | no -- restore will change it |
What restore will change — live diff
Left column shows current on-disk content; right shows what restore will write. +0 additions, -31 deletions, 146 unchanged context lines.
| 1 | 1 | <div class="page-head"> |
| 2 | 2 | <span class="page-eyebrow"><span class="dot"></span> Restore</span> |
| 3 | 3 | <h1 class="page-title">Restore file to captured state</h1> |
| 4 | 4 | <p class="page-subtitle">Every captured change carries its SHA-256-addressed content in BLOB_STORE. Restoring writes that content back to the original path — current file gets backed up to <code><path>.drift_restore_backup_<epoch></code> before overwrite.</p> |
| 5 | 5 | </div> |
| 6 | 6 | |
| 7 | 7 | [if:$has_error] |
| 8 | 8 | <div class="module glow-rose"> |
| 9 | 9 | <div class="module-head"><div class="left"> |
| 10 | 10 | <div class="module-title">Cannot proceed</div> |
| 11 | 11 | <span class="module-subtitle">Restore rejected on safety grounds.</span> |
| 12 | 12 | </div></div> |
| 13 | 13 | <div class="module-body" style="color:var(--accent-danger-hi)"> |
| 14 | 14 | $error_msg |
| 15 | 15 | </div> |
| 16 | 16 | </div> |
| 17 | 17 | [/if] |
| 18 | 18 | |
| 19 | 19 | [if:$did_restore] |
| 20 | 20 | [if:$result_ok] |
| 21 | 21 | <div class="module glow-emerald"> |
| 22 | 22 | <div class="module-head"><div class="left"> |
| 23 | 23 | <div class="module-icon"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg></div> |
| 24 | 24 | <div class="module-title">Restore succeeded</div> |
| 25 | 25 | <span class="module-subtitle">Content at <code>$target_file</code> now matches captured SHA <code>$source_sha</code>. Prior content is safe in the backup file.</span> |
| 26 | 26 | </div></div> |
| 27 | 27 | <div class="module-body"> |
| 28 | 28 | <table class="tbl"> |
| 29 | 29 | <tbody> |
| 30 | 30 | <tr><td style="width:200px"><strong>Target</strong></td><td class="mono">$target_file</td></tr> |
| 31 | 31 | <tr><td><strong>Server</strong></td><td class="mono">$server_name (<span class="dim">$server_kind</span>)</td></tr> |
| 32 | 32 | <tr><td><strong>Restored content SHA</strong></td><td class="mono">$source_sha</td></tr> |
| 33 | 33 | <tr><td><strong>Captured at</strong></td><td class="mono dim"><span class="ts" data-ts="$captured_epoch" data-fmt="datetime">$captured_h</span></td></tr> |
| 34 | 34 | <tr><td><strong>Backup file</strong></td><td class="mono dim">[if:$backup_path]$backup_path[/if][if:!$backup_path](no prior content to back up)[/if]</td></tr> |
| 35 | 35 | <tr><td><strong>Result</strong></td><td>$result_msg</td></tr> |
| 36 | 36 | </tbody> |
| 37 | 37 | </table> |
| 38 | 38 | <div style="margin-top:14px"> |
| 39 | 39 | <a href="/file_changes.cgi" class="tr-chip">Back to file changes</a> |
| 40 | 40 | <a href="/diff.cgi?kind=file&id=$id" class="tr-chip">See diff</a> |
| 41 | 41 | </div> |
| 42 | 42 | </div> |
| 43 | 43 | </div> |
| 44 | 44 | [/if] |
| 45 | 45 | [if:!$result_ok] |
| 46 | 46 | <div class="module glow-rose"> |
| 47 | 47 | <div class="module-head"><div class="left"> |
| 48 | 48 | <div class="module-title">Restore failed</div> |
| 49 | 49 | <span class="module-subtitle">See RESTORE_LOG for full audit trail.</span> |
| 50 | 50 | </div></div> |
| 51 | 51 | <div class="module-body"> |
| 52 | 52 | <p style="color:var(--accent-danger-hi)">$result_msg</p> |
| 53 | 53 | <p class="dim" style="font-size:12.5px;margin-top:8px">Backup path: <code>$backup_path</code></p> |
| 54 | 54 | </div> |
| 55 | 55 | </div> |
| 56 | 56 | [/if] |
| 57 | 57 | [/if] |
| 58 | 58 | |
| 59 | 59 | [if:!$did_restore][if:!$has_error] |
| 60 | 60 | <div class="dash-grid" style="grid-template-columns:1fr 1fr"> |
| 61 | 61 | <div class="module glow-teal"> |
| 62 | 62 | <div class="module-head"><div class="left"> |
| 63 | 63 | <div class="module-title">What will change</div> |
| 64 | 64 | <span class="module-subtitle">Preview -- nothing has been written yet.</span> |
| 65 | 65 | </div></div> |
| 66 | 66 | <div class="module-body"> |
| 67 | 67 | <table class="tbl"> |
| 68 | 68 | <tbody> |
| 69 | 69 | <tr><td style="width:170px"><strong>Target file</strong></td><td class="mono">$target_file</td></tr> |
| 70 | 70 | <tr><td><strong>Site</strong></td><td>$scan_name <span class="dim">on $server_name</span></td></tr> |
| 71 | 71 | <tr><td><strong>Kind</strong></td><td>$server_kind</td></tr> |
| 72 | 72 | <tr><td><strong>Captured at</strong></td><td class="mono dim"><span class="ts" data-ts="$captured_epoch" data-fmt="datetime">$captured_h</span></td></tr> |
| 73 | 73 | <tr><td><strong>Captured SHA</strong></td><td class="mono">$source_sha_full</td></tr> |
| 74 | 74 | </tbody> |
| 75 | 75 | </table> |
| 76 | 76 | </div> |
| 77 | 77 | </div> |
| 78 | 78 | <div class="module glow-amber"> |
| 79 | 79 | <div class="module-head"><div class="left"> |
| 80 | 80 | <div class="module-title">Current state on disk</div> |
| 81 | 81 | <span class="module-subtitle">Live check just now. If SHAs match, the restore is a no-op.</span> |
| 82 | 82 | </div></div> |
| 83 | 83 | <div class="module-body"> |
| 84 | 84 | <table class="tbl"> |
| 85 | 85 | <tbody> |
| 86 | 86 | <tr><td style="width:170px"><strong>File present</strong></td><td>[if:$current_exists]<span class="pill pill-ok">yes</span>[/if][if:!$current_exists]<span class="pill pill-mute">no (new file)</span>[/if]</td></tr> |
| 87 | 87 | <tr><td><strong>Size</strong></td><td class="mono dim">$current_size</td></tr> |
| 88 | 88 | <tr><td><strong>Current SHA</strong></td><td class="mono">$current_sha</td></tr> |
| 89 | 89 | <tr><td><strong>Same as captured?</strong></td><td>[if:$same_content]<span class="pill pill-ok">yes -- no-op</span>[/if][if:!$same_content]<span class="pill pill-warn">no -- restore will change it</span>[/if]</td></tr> |
| 90 | 90 | </tbody> |
| 91 | 91 | </table> |
| 92 | 92 | <div style="margin-top:14px"> |
| 93 | 93 | <a href="$diff_url" class="tr-chip">See exactly what's different →</a> |
| 94 | 94 | </div> |
| 95 | 95 | </div> |
| 96 | </div> | |
| 97 | </div> | |
| 98 | ||
| 99 | [if:$has_recent_restores] | |
| 100 | <div class="module glow-warn" style="margin-top:16px"> | |
| 101 | <div class="module-head"><div class="left"> | |
| 102 | <div class="module-title">Recent restores of this file</div> | |
| 103 | <span class="module-subtitle">This file has been restored before — check whether you want to duplicate that action or pick a different captured moment.</span> | |
| 104 | </div></div> | |
| 105 | <div class="module-body tight"> | |
| 106 | <table class="tbl"> | |
| 107 | <thead><tr> | |
| 108 | <th style="width:100px">Status</th> | |
| 109 | <th style="width:120px">Source SHA</th> | |
| 110 | <th>By</th> | |
| 111 | <th>Error</th> | |
| 112 | <th style="width:150px">When</th> | |
| 113 | </tr></thead> | |
| 114 | <tbody> | |
| 115 | [loop:@recent_restores_this] | |
| 116 | <tr> | |
| 117 | <td><span class="pill $status_pill">$status</span></td> | |
| 118 | <td class="mono">$sha_short</td> | |
| 119 | <td class="dim">$restored_by</td> | |
| 120 | <td class="mono dim" style="font-size:11.5px">$err_short</td> | |
| 121 | <td class="mono dim"><span class="ts" data-ts="$restored_epoch" data-fmt="relative">$restored_h</span></td> | |
| 122 | </tr> | |
| 123 | [/loop] | |
| 124 | </tbody> | |
| 125 | </table> | |
| 126 | 96 | </div> |
| 127 | 97 | </div> |
| 128 | [/if] | |
| 129 | 98 | |
| 130 | 99 | [if:$has_live_diff] |
| 131 | 100 | <div class="module glow-teal" style="margin-top:20px"> |
| 132 | 101 | <div class="module-head"><div class="left"> |
| 133 | 102 | <div class="module-icon"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2"><polyline points="8 3 4 7 8 11"/><polyline points="16 21 20 17 16 13"/><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="17" x2="20" y2="17"/></svg></div> |
| 134 | 103 | <div class="module-title">What restore will change — live diff</div> |
| 135 | 104 | <span class="module-subtitle">Left column shows current on-disk content; right shows what restore will write. <strong>+$diff_add</strong> additions, <strong>-$diff_del</strong> deletions, $diff_ctx unchanged context lines.</span> |
| 136 | 105 | </div></div> |
| 137 | 106 | <div class="module-body tight"> |
| 138 | 107 | <style> |
| 139 | 108 | .rst-diff { width:100%; border-collapse:collapse; font-family:var(--mono); font-size:12px; line-height:1.5; } |
| 140 | 109 | .rst-diff td { padding:1px 8px; vertical-align:top; white-space:pre-wrap; word-wrap:break-word; } |
| 141 | 110 | .rst-diff .ln { color:var(--text-muted); text-align:right; width:44px; user-select:none; border-right:1px solid var(--border); font-size:11px; } |
| 142 | 111 | .rst-diff tr.op-add td.text { background:rgba(52,211,153,.10); color:#a7f3d0; } |
| 143 | 112 | .rst-diff tr.op-add td.text::before { content:'+'; color:var(--accent-ok); padding-right:6px; } |
| 144 | 113 | .rst-diff tr.op-del td.text { background:rgba(244,63,94,.10); color:var(--accent-danger-hi); } |
| 145 | 114 | .rst-diff tr.op-del td.text::before { content:'-'; color:var(--accent-danger); padding-right:6px; } |
| 146 | 115 | .rst-diff tr.op-ctx td { color:var(--text-dim); } |
| 147 | 116 | .rst-diff tr.op-ctx td.text::before { content:' '; padding-right:6px; } |
| 148 | 117 | </style> |
| 149 | 118 | <div style="max-height:50vh;overflow:auto"> |
| 150 | 119 | <table class="rst-diff"> |
| 151 | 120 | <tbody> |
| 152 | 121 | [loop:@diff_lines]<tr class="op-$op"><td class="ln">$old_n</td><td class="ln">$new_n</td><td class="text">$text</td></tr>[/loop] |
| 153 | 122 | </tbody> |
| 154 | 123 | </table> |
| 155 | 124 | </div> |
| 156 | 125 | </div> |
| 157 | 126 | </div> |
| 158 | 127 | [/if] |
| 159 | 128 | |
| 160 | 129 | <div class="module glow-rose" style="margin-top:20px"> |
| 161 | 130 | <div class="module-head"><div class="left"> |
| 162 | 131 | <div class="module-title">Confirm restore</div> |
| 163 | 132 | <span class="module-subtitle">Backs current content to <code><target>.drift_restore_backup_<epoch></code>, writes the captured content, verifies SHA post-write.</span> |
| 164 | 133 | </div></div> |
| 165 | 134 | <div class="module-body"> |
| 166 | 135 | <form method="post" action="/restore.cgi" style="display:flex;gap:12px;align-items:center"> |
| 167 | 136 | <input type="hidden" name="id" value="$id"> |
| 168 | 137 | <input type="hidden" name="confirm" value="1"> |
| 169 | 138 | <button type="submit" class="tr-chip is-active" style="border:none;padding:8px 22px;background:var(--accent-danger);border-color:var(--accent-danger);color:#fff"> |
| 170 | 139 | Yes, restore this file |
| 171 | 140 | </button> |
| 172 | 141 | <a href="/file_changes.cgi" class="tr-chip">Cancel</a> |
| 173 | 142 | <span class="dim" style="margin-left:auto;font-size:12px">Logged to RESTORE_LOG regardless of outcome.</span> |
| 174 | 143 | </form> |
| 175 | 144 | </div> |
| 176 | 145 | </div> |
| 177 | 146 | [/if][/if] |
Confirm restore
Backs current content to <target>.drift_restore_backup_<epoch>, writes the captured content, verifies SHA post-write.