Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
762 lines (617 loc) · 44.8 KB
/
Copy pathindex.html
File metadata and controls
762 lines (617 loc) · 44.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>secureblue-backup</title>
<style>
:root {
--bg: #0d1117;
--fg: #c9d1d9;
--muted: #8b949e;
--border: #30363d;
--card: #161b22;
--accent: #58a6ff;
--ok: #3fb950;
--warn: #d29922;
--danger: #f85149;
}
* { box-sizing: border-box; }
body {
margin: 0;
padding: 0;
background: var(--bg);
color: var(--fg);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
line-height: 1.6;
}
.container {
max-width: 900px;
margin: 0 auto;
padding: 2rem 1.5rem;
}
h1 {
font-size: 2rem;
border-bottom: 1px solid var(--border);
padding-bottom: .5rem;
margin-bottom: 1rem;
}
h2 {
font-size: 1.4rem;
margin-top: 2.5rem;
padding-bottom: .4rem;
border-bottom: 1px solid var(--border);
}
h3 {
font-size: 1.15rem;
margin-top: 2rem;
color: var(--fg);
border-left: 2px solid var(--accent);
padding-left: .8rem;
}
h2.topic {
color: var(--accent);
}
h2.phase {
color: var(--accent);
}
.symptom {
background: rgba(248,81,73,.08);
border-left: 3px solid var(--danger);
padding: .7rem 1rem;
margin: .6rem 0;
border-radius: 0 6px 6px 0;
}
.cause {
background: rgba(210,153,34,.08);
border-left: 3px solid var(--warn);
padding: .7rem 1rem;
margin: .6rem 0;
border-radius: 0 6px 6px 0;
}
.fix {
background: rgba(63,185,80,.08);
border-left: 3px solid var(--ok);
padding: .7rem 1rem;
margin: .6rem 0;
border-radius: 0 6px 6px 0;
}
p { margin: .8rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre {
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
font-size: .9rem;
}
code {
background: var(--card);
padding: .15rem .35rem;
border-radius: 4px;
border: 1px solid var(--border);
}
pre {
background: var(--card);
border: 1px solid var(--border);
border-radius: 6px;
padding: 1rem;
overflow-x: auto;
line-height: 1.45;
}
pre code {
background: none;
padding: 0;
border: none;
}
.critical {
background: rgba(248,81,73,.1);
border-left: 4px solid var(--danger);
padding: .8rem 1rem;
margin: 1rem 0;
border-radius: 0 6px 6px 0;
}
.note {
background: rgba(41,128,185,.1);
border-left: 4px solid var(--accent);
padding: .8rem 1rem;
margin: 1rem 0;
border-radius: 0 6px 6px 0;
}
.screenshot {
margin: 1rem 0;
text-align: center;
}
.screenshot img {
max-width: 100%;
height: auto;
border: 1px solid var(--border);
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.screenshot .caption {
color: var(--muted);
font-size: .9rem;
margin-top: .5rem;
}
.stack {
display: flex;
flex-direction: column;
gap: .5rem;
margin: 1.5rem 0;
}
.layer {
padding: .9rem 1rem;
border-radius: 6px;
font-weight: 600;
}
.layer small {
display: block;
font-weight: 400;
color: rgba(255,255,255,.85);
margin-top: .2rem;
}
.l-user { background: #f85149; }
.l-config { background: #d29922; }
.l-packages { background: #a371f7; }
.l-deploy { background: #58a6ff; }
.l-base { background: #3fb950; }
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
}
th, td {
border: 1px solid var(--border);
padding: .6rem .8rem;
text-align: left;
}
th { background: var(--card); }
ul { margin: .5rem 0; padding-left: 1.5rem; }
li { margin: .35rem 0; }
</style>
<base target="_blank">
<base target="_blank">
<base target="_blank">
</head>
<body>
<div class="container">
<h1>secureblue-backup</h1>
<p>Backup and disaster recovery for <a href="https://secureblue.dev/">secureblue OS</a>.</p>
<p>This guide documents how to preserve, verify, and reconstruct a secureblue system after hardware failure, migration, or catastrophic misconfiguration. It's not about finding a new backup tool; it's about applying existing tools correctly to an atomic filesystem layout.</p>
<h2>Stack Diagram</h2>
<div class="stack">
<div class="layer l-user">
User Data
<small>Home directory, excluding cache and temp</small>
</div>
<div class="layer l-config">
System Config
<small>/etc overrides, /var persistent state, custom systemd units</small>
</div>
<div class="layer l-packages">
Layered Packages
<small>rpm-ostree install list for reproducible rebuilds</small>
</div>
<div class="layer l-deploy">
Deployment State
<small>Current deployment hash, rollback history, pinned deployments</small>
</div>
<div class="layer l-base">
secureblue Base
<small>Atomic OS / Restored via rebase, not backed up</small>
</div>
</div>
<p>Think of the stack as layers of paint. The green base layer (<code>/usr</code>) is factory paint; you never touch it. The blue, purple, orange, and red layers above it are your personal paint - configs, packages, and data. When disaster strikes, we throw away the canvas and repaint the base, then re-apply only your personal layers.</p>
<h2 class="topic">Prerequisites</h2>
<p>This guide assumes you are running secureblue (or another rpm-ostree system) and are comfortable with terminal commands. Three axioms govern atomic backup strategy. First, <code>/usr</code> is a read-only OSTree checkout - managed base state that is never backed up; it is rebased. Second, Btrfs deployment snapshots are local-only recovery tools; they die with the disk and do not constitute backups. Third, a backup plan is only valid after it has been tested end-to-end. If you do not understand why <code>/usr</code> is excluded or why snapshots are insufficient, review the <a href="https://coreos.github.io/rpm-ostree/administrator-handbook/">rpm-ostree administrator handbook</a> before proceeding.</p>
<div class="note">
<strong>New to atomic systems?</strong> On a traditional Linux distro, you install packages directly into <code>/usr</code> and they become part of your system forever. On an atomic system, <code>/usr</code> is a read-only snapshot (an <em>OSTree deployment</em>) that is replaced entirely during updates. Your changes - config files, layered packages, service state - live in separate <em>overlay</em> layers on top of that snapshot. This guide backs up those overlays so you can re-apply them to a fresh deployment.
</div>
<h2 class="topic">What this guide captures</h2>
<p>Atomic systems separate managed base state (<code>/usr</code>) from mutable overlays (<code>/etc</code>, <code>/var</code>, layered packages, user data). A valid backup strategy must capture the deltas, not the baseline. This guide documents those deltas and their restoration order.</p>
<h2 class="topic">What it does</h2>
<p>The strategy consists of five components working together:</p>
<ul>
<li><strong>User Data:</strong> Selective home directory backup, excluding cache, temp, and Flatpak runtime data. This is your documents, projects, and personal files.</li>
<li><strong>System Config:</strong> Capture of /etc overrides, /var persistent state, and custom systemd units. These are the changes you made to the system that survive reboots but aren't part of the base image.</li>
<li><strong>Layered Packages:</strong> Reproducible package list export for rpm-ostree rebuilds. This ensures you can reconstruct the exact same software environment after a rebase.</li>
<li><strong>Deployment State:</strong> Deployment hash, rollback history, and pinned deployment tracking. This gives you a snapshot of where you were in the update stream.</li>
<li><strong>Verification:</strong> Automated restore testing and integrity checks. A backup you've never tested is a false promise.</li>
</ul>
<h2 class="topic">The atomic backup mindset</h2>
<p>This guide assumes a different mindset: the base image is disposable, the overlays are precious, and the goal is reconstruction, not cloning. You're not preserving a machine; you're preserving the deviation from a known good baseline.</p>
<h3>When this matters</h3>
<ul>
<li><strong>Drive failure:</strong> New hardware arrives blank. You need to reconstruct your environment without remembering every package you layered or every config file you touched six months ago.</li>
<li><strong>Bad rebase:</strong> You moved to a new secureblue image and something critical broke. You need to return to your previous deployment and package state quickly.</li>
<li><strong>Migration:</strong> You bought a new machine and want to move your setup without the archaeological dig of remembering what you changed.</li>
<li><strong>Configuration drift:</strong> You modified <code>/etc</code> over months and lost track. A captured config diff shows exactly what differs from base, which is invaluable for troubleshooting.</li>
</ul>
<h3>What "reconstruction" means</h3>
<p>Restoration on an atomic system isn't <code>tar xzf backup.tar -C /</code>. It's:</p>
<ol>
<li>Rebase to the same (or newer) base image</li>
<li>Reinstall the exact layered package set</li>
<li>Restore <code>/etc</code> and selective <code>/var</code> state on top of the new base</li>
<li>Restore user data from your file-level backup</li>
<li>Reboot into a system that behaves like the old one, built on fresh deployment metadata</li>
</ol>
<p>This is cleaner than cloning because it eliminates accumulated deployment cruft. Every restore is essentially a clean install plus your documented deviations.</p>
<h2 class="topic">Btrfs snapshots: useful, but not sufficient</h2>
<p>An rpm-ostree deployment snapshot is a local rollback point stored on your system disk. It lets you undo a bad update from the bootloader, but it cannot survive disk failure.</p>
<p>Fedora's atomic desktops and secureblue use Btrfs for <code>/sysroot</code>. The <code>rpm-ostree</code> tooling already creates deployment snapshots automatically every time you install, update, or rebase. You can roll back to a previous deployment from the bootloader menu if a new update breaks something. This is powerful local recovery.</p>
<p>This guide treats snapshots as the first line of defense for daily mistakes, and off-system backups as the second line for disaster recovery. You should have both.</p>
<h3>How snapshots fit into this strategy</h3>
<ul>
<li><strong>Daily mistakes:</strong> Revert a bad config edit or broken package layer via the bootloader rollback menu. Fast, no external media needed.</li>
<li><strong>Pre-rebase safety:</strong> Pin your current deployment before rebasing. If the new image fails, roll back instantly.</li>
<li><strong>Not for drive failure:</strong> When the disk dies, snapshots die with it. That's where Phase 2 and your external backup matter.</li>
</ul>
<h2 class="topic">Why this guide mixes GUI and terminal</h2>
<p>Pika Backup handles your personal files through a graphical interface because standard file backup is a solved problem with good GUI tools. The system state capture, however, remains command-line only. No graphical application currently understands rpm-ostree deployments, layered packages, or the three-way merge model of <code>/etc</code>. Until someone builds an atomic-aware backup GUI, the system-level phases require direct interaction with <code>rpm-ostree</code>, <code>tar</code>, and deployment metadata.</p>
<h2 class="phase">Phase 0: Pre-flight Inventory</h2>
<div class="critical">
<strong>CRITICAL:</strong> Don't back up blindly. You must understand what state exists before you can preserve it. This phase is read-only; it changes nothing.
</div>
<h3>1. Inspect current deployment</h3>
<pre><code># Show current deployment, pending updates, and rollback history
rpm-ostree status 2>/dev/null</code></pre>
<p>Save this output. It contains your current deployment hash, the image reference, and any pinned deployments you want to keep.</p>
<h3>2. Identify layered packages</h3>
<pre><code># List packages layered via rpm-ostree install
rpm-ostree status --booted 2>/dev/null | grep "LayeredPackages:"</code></pre>
<p>Alternatively, capture the full status as JSON for later parsing:</p>
<pre><code>rpm-ostree status --json 2>/dev/null > ~/secureblue-backup-deployments.json</code></pre>
<h3>3. Inspect /etc drift</h3>
<p><strong>Drift</strong> is any file in <code>/etc</code> that differs from the base image's default. rpm-ostree tracks this automatically. The command below shows your drift using the canonical rpm-ostree view:</p>
<pre><code># Show files in /etc that differ from the base image (canonical rpm-ostree view)
run0 /usr/bin/ostree admin config-diff 2>/dev/null | /usr/bin/head -n 50</code></pre>
<div class="note">
<strong>Skip:</strong> backup copies (trailing <code>-</code>), lock files (<code>.LOCK</code>), stamp files, identity files (<code>passwd</code>, <code>group</code>, <code>machine-id</code>, <code>adjtime</code>, <code>hostname</code>, <code>localtime</code>), auto-generated state (<code>fstab</code>, <code>cups/subscriptions.conf*</code>, <code>dconf/db/distro</code>, <code>nvme/hostid</code>, <code>nvme/hostnqn</code>, <code>selinux/*</code>), and ephemeral flags (<code>.pwd.lock</code>, <code>.rpm-ostree-shadow-mode-fixed2.stamp</code>).<br><br>
<strong>Preserve:</strong> only files you explicitly created or edited.
</div>
<h3>4. Inspect /var state</h3>
<p>On atomic systems, <code>/var</code> holds system-level persistent state (network profiles, Bluetooth keys, container storage) that survives reboots but is not part of the base image. Unlike <code>/home</code>, it is owned by the system, not by you.</p>
<pre><code># Identify large or important persistent state in /var
run0 /usr/bin/du -sh /var/lib/* 2>/dev/null | sort -rh | head -n 20</code></pre>
<div class="note">
<strong>Preserve:</strong> <code>/var/lib/NetworkManager</code> (connection profiles and keys) <em>only if you use NetworkManager-managed VPNs</em>; skip this if you use a standalone VPN client like IVPN, which stores settings in <code>/opt/ivpn/etc/</code> and <code>~/.config/ivpn/</code>. Also preserve <code>/var/lib/bluetooth</code> (pairing keys), <code>/var/lib/boltd</code> (Thunderbolt authorization), and <code>/var/lib/containers</code> (Podman images) if you use containers.<br><br>
<strong>Skip:</strong> <code>/var/lib/rpm-ostree</code> (deployment metadata tied to this disk), <code>/var/lib/systemd</code> (machine-specific random seeds and runtime tracking), auto-generated service state (<code>fwupd</code>, <code>chrony</code>, <code>alsa</code>, <code>upower</code>), ephemeral system state (<code>AccountsService</code>, <code>lastlog</code>), and metrics (<code>rpm-ostree-countme</code>, <code>secureblue</code>).
</div>
<div class="note">
<strong>Warning:</strong> <code>/var/lib/containers</code> (Podman) and <code>/var/lib/libvirt</code> can grow to tens or hundreds of gigabytes. A <code>tar</code> archive of this data may exceed your backup disk capacity. Consider exporting container images with <code>podman save</code> or backing up VM disks individually rather than archiving the entire <code>/var/lib</code> directory.
</div>
<div class="note">
<strong>Note:</strong> <code>/var/lib/bluetooth</code> contains pairing keys tied to your specific Bluetooth controller MAC address. <code>/var/lib/boltd</code> contains Thunderbolt authorizations tied to specific devices and ports. Restoring these to different hardware is usually pointless. Only preserve them when restoring to the same machine.
</div>
<h2 class="phase">Phase 1: Capture System State</h2>
<div class="critical">
<strong>CRITICAL:</strong> All commands in this phase use absolute paths because secureblue's <code>run0</code> wrapper strips <code>/usr/sbin</code> and <code>/sbin</code> from PATH. Copy-pasting standard commands will fail with "command not found."
</div>
<h3>1. Create backup staging directory</h3>
<pre><code># Create a dedicated directory for all captured state
# Use /var/home/$USER (your actual home) because /home is a symlink on some deployments
/usr/bin/mkdir -p /var/home/$(/usr/bin/whoami)/secureblue-backup/{configs,packages,deployments,scripts}</code></pre>
<h3>2. Export deployment state</h3>
<pre><code># We save the deployment metadata so we know exactly which base image to rebase to later
rpm-ostree status --json 2>/dev/null > /var/home/$(/usr/bin/whoami)/secureblue-backup/deployments/rpm-ostree-status.json
# Save the current image reference in plain text for quick rebasing
rpm-ostree status --booted 2>/dev/null | /usr/bin/grep -o 'ostree-[^[:space:]]*' | /usr/bin/head -n 1 > /var/home/$(/usr/bin/whoami)/secureblue-backup/deployments/current-image-ref.txt</code></pre>
<h3>3. Export layered package list</h3>
<pre><code># Layered packages live outside the base image in a separate layer.
# We extract them from rpm-ostree's JSON metadata to avoid brittle text parsing.
/usr/bin/python3 -c "import sys,json; d=json.load(sys.stdin); [print(p) for dep in d.get('deployments',[]) if dep.get('booted') for p in dep.get('requested-packages',[])]" < <(rpm-ostree status --json) > /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/layered-packages.txt
# Also capture the exact rpm-ostree install command for documentation
/usr/bin/echo "rpm-ostree install $(/usr/bin/paste -sd' ' /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/layered-packages.txt)" > /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/reinstall-command.sh
/usr/bin/chmod +x /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/reinstall-command.sh</code></pre>
<h3>4. Capture /etc overrides</h3>
<pre><code># Create a tar archive of /etc, preserving permissions and SELinux contexts
# Exclude ephemeral directories that shouldn't be preserved
run0 /usr/bin/tar czpf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/etc-backup.tar.gz --exclude=/etc/resolv.conf --exclude=/etc/localtime --exclude=/etc/machine-id --exclude=/etc/hostname --exclude=/etc/mtab --exclude=/etc/fstab /etc</code></pre>
<div class="note">
<strong>Note:</strong> Tar will print "Removing leading '/' from member names." This is harmless. Tar strips the leading slash as a security precaution when archiving absolute paths. Restoration with <code>-C /</code> still places files in the correct location.
</div>
<div class="note">
<strong>Note:</strong> The exclusions above are ephemeral or auto-generated. Machine-id and hostname in particular shouldn't be blindly restored to new hardware. <code>/etc/fstab</code> on rpm-ostree is typically empty or auto-generated and should not be carried across deployments. If you've installed my <a href="https://github.com/x144k/secureblue-hids">secureblue-hids</a> stack, add <code>--exclude=/etc/audit/rules.d/*</code> to the tar command above. Audit rules in that stack are managed by its own installation procedure; restoring them from a generic /etc backup would either conflict with that managed state or miss dependencies installed by its scripts. If you've applied that stack, reinstall audit rules via the HIDS guide instead.
</div>
<h3>5. Capture /var persistent state</h3>
<pre><code># Identify what in /var you actually need. This is selective, not blanket.
# Create a manifest of /var directories you want to preserve
/usr/bin/cat > /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/var-manifest.txt << 'EOF'
# Uncomment the lines below for what you want to preserve:
# /var/lib/containers # Podman container images and volumes (see size warning above)
# /var/lib/libvirt # Virtual machine images
# /var/lib/flatpak # Flatpak system runtimes (not user app data)
# /var/lib/NetworkManager # Network connection profiles
# /var/log/journal # Persistent journal logs
# /var/spool # Mail and cron spools
EOF</code></pre>
<p>Edit the manifest to match your needs, then archive the selected paths:</p>
<pre><code># Example: backing up NetworkManager state and mail/cron spools only (skip if you use IVPN or another standalone VPN)
run0 /usr/bin/tar czpf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/var-selective.tar.gz /var/lib/NetworkManager /var/spool</code></pre>
<div class="note">
<strong>Note:</strong> Tar will print "Removing leading '/' from member names" and "Removing leading '/' from hard link targets." Both are harmless. If you include <code>/var/log/journal</code>, you may also see "file changed as we read it" for active journal files. This is expected; journald is actively writing while tar reads. The archive will still be valid.
</div>
<h3>6. Capture custom systemd units</h3>
<pre><code># Custom units in /etc/systemd/system are already captured in the /etc tar
# This step captures any user-level units in ~/.config/systemd/user
/usr/bin/mkdir -p /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/user-systemd
/usr/bin/cp -r ~/.config/systemd/user/* /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/user-systemd/ 2>/dev/null || true</code></pre>
<h3>7. Fix backup ownership</h3>
<pre><code># The tar archives above were created with run0 (root), so Pika cannot read them.
# Fix ownership so your user can back them up in Phase 2.
run0 /usr/bin/chown -R $(/usr/bin/whoami):$(/usr/bin/whoami) /var/home/$(/usr/bin/whoami)/secureblue-backup</code></pre>
<div class="note">
<strong>Note:</strong> Without this step, Pika Backup will fail with <code>Permission denied</code> when trying to read <code>etc-backup.tar.gz</code> and <code>var-selective.tar.gz</code>.
</div>
<h2 class="phase">Phase 2: User Data Backup with Pika Backup</h2>
<p>Pika Backup is a graphical front-end for BorgBackup. It handles encryption, compression, scheduling, and exclusion lists through a clean GTK4 interface. This phase replaces command-line Borg with Pika for the user data portion of the backup.</p>
<div class="note">
<strong>Note:</strong> Pika Backup handles your personal files only. The system state capture in Phase 1 still requires command-line tools because no GUI currently understands rpm-ostree deployments.
</div>
<h3>1. Install Pika Backup</h3>
<p><strong>Option A: GUI install (recommended for most users)</strong></p>
<p>Open Bazaar, the software center that ships with secureblue. Search for "Pika Backup." Install the verified application. Secureblue enables only the <code>flathub-verified</code> remote by default, which filters to verified developers only. Bazaar will pull from this restricted source automatically.</p>
<div class="screenshot">
<img src="images/1-pika-bazaar.webp" alt="Pika Backup in Bazaar">
<p class="caption">Install Pika Backup from the verified Flathub source in your software center.</p>
</div>
<p><strong>Option B: Command line</strong></p>
<pre><code>flatpak install flathub-verified org.gnome.World.PikaBackup</code></pre>
<p>Use this if you prefer the terminal or are scripting the setup. The <code>flathub-verified</code> remote is the default on secureblue; don't use the unqualified <code>flathub</code> remote.</p>
<h3>2. Launch and start creating a repository</h3>
<p>Open Pika Backup. On the initial screen, click <strong>Setup Backup</strong>. Then click <strong>Create Repository</strong> and choose either <strong>Location on Disk</strong>, or point it to an external drive with a dedicated backup directory. The <strong>Remote Location</strong> option is beyond the scope of this guide.</p>
<div class="screenshot">
<img src="images/2-pika-backup-initial.webp" alt="Pika Backup initial screen">
<p class="caption">Start creating a repository from the initial screen.</p>
</div>
<h3>3. Configure repository details and encryption</h3>
<p>On the <strong>Configure Repository</strong> screen, alter the repository folder and name as needed. Then click <strong>Continue</strong>.</p>
<div class="screenshot">
<img src="images/3a-pika-repo.webp" alt="Pika Backup configure repository">
<p class="caption">Set the repository folder and name on the Configure Repository screen.</p>
</div>
<p>On the <strong>Setup Encryption</strong> screen, decide whether you want encryption. If you enable it, set a strong password and back it up somewhere secure before proceeding. Without this password, your backup is unrecoverable. If you don't want encryption, leave the toggle off. Then click <strong>Create</strong> to finalize the repository.</p>
<div class="screenshot">
<img src="images/3b-pika-encrypt.webp" alt="Pika Backup encryption setup">
<p class="caption">Configure encryption before creating the repository.</p>
</div>
<h3>4. Configure exclusions</h3>
<p>After the repository is created, you're returned to the main screen. Click <strong>Exclude From Backup</strong> to open the exclusions dialog.</p>
<div class="critical">
<strong>WARNING:</strong> Pika's <strong>Exclude Folders</strong> and <strong>Exclude Files</strong> options require the path to already exist on disk. If you select a path that does not exist, Pika may default to the parent directory and unintentionally exclude your entire home folder. For safety, use <strong>Exclude Pattern</strong> for any path that might not exist.
</div>
<p><strong>Step 1: Enable suggested exclusions.</strong> Pika provides checked suggestions for common ephemeral data. Enable these:</p>
<ul>
<li><strong>Caches</strong> - covers <code>.cache</code> and <code>.thumbnails</code></li>
<li><strong>Trash</strong> - covers <code>.local/share/Trash</code></li>
<li><strong>Virtual Machines and Containers</strong> - covers large VM images if present</li>
</ul>
<p><strong>Do NOT enable:</strong></p>
<ul>
<li><strong>Flatpak App Installations</strong> — this excludes <code>.var/app/</code>, which contains your actual Flatpak app data, settings, and documents. The system-wide runtime installations in <code>/var/lib/flatpak</code> are redownloadable and handled separately in the system state capture if you choose to back them up; your personal app data is not.</li>
</ul>
<div class="note">
<strong>Note:</strong> If you exclude <code>.var/app</code>, you will lose all documents, settings, and state stored inside Flatpak applications (Discord, browsers, games, etc.). Only enable this if you truly have no Flatpak app data worth preserving.
</div>
<p><strong>Step 2: Add custom patterns.</strong> Click <strong>Exclude Pattern</strong> and ensure the type is set to <strong>Unix Filename Pattern</strong> (the default). I added these patterns after noticing they were eating space:</p>
<ul>
<li><code>*/node_modules</code> - folders that show up when installing software dependencies</li>
<li><code>*/target</code> - build output that appears after compiling software</li>
<li><code>*/dist</code> - packaged files created by some applications</li>
<li><code>*/build</code> - temporary directories created during installation</li>
<li><code>*.log</code> - text files that grow constantly and are not worth backing up</li>
<li><code>Downloads/*.iso</code> - operating system installers I can always download again</li>
<li><code>Downloads/*.img</code> - disk images I can always download again</li>
</ul>
<div class="screenshot">
<img src="images/4-pika-exclude.webp" alt="Pika Backup exclusion dialog">
<p class="caption">Enable suggested exclusions and add custom patterns.</p>
</div>
<h3>5. Run the first backup and optional scheduling</h3>
<p>Click <strong>Back Up Now</strong> on the main screen to begin your first backup.</p>
<div class="screenshot">
<img src="images/5-pika-progress.webp" alt="Pika Backup during backup">
<p class="caption">First backup in progress.</p>
</div>
<p><strong>Optional:</strong> Click the <strong>Schedule</strong> tab on the main screen to enable automatic daily or weekly backups. Pika uses a background service that runs even when the main window is closed. This step is optional; manual backups are sufficient if you prefer to control when they run.</p>
<div class="screenshot">
<img src="images/6-pika-schedule.webp" alt="Pika Backup schedule tab">
<p class="caption">Optional: enable automatic scheduled backups from the Schedule tab.</p>
</div>
<h3>6. Verify the archive</h3>
<p>Click <strong>the Archives</strong> tab on the main screen. You should see your first archive listed with a timestamp and size. Click it to browse the contents and confirm your important directories are present. Optionally, perform a Data Integrity Check.</p>
<div class="screenshot">
<img src="images/7-pika-archives.webp" alt="Pika Backup archives">
<p class="caption">Verify the completed archive in the Archives view.</p>
</div>
<h3>Command-line alternative</h3>
<p>If you prefer not to use a GUI, the underlying Borg repository created by Pika is standard and can be manipulated from the terminal. First, install borgbackup on the host system:</p>
<pre><code>rpm-ostree install borgbackup
# Reboot to activate the new deployment
systemctl reboot</code></pre>
<p>Then use borg commands against the repository Pika created. The repository path matches the folder you selected during setup, and archive names use timestamps:</p>
<pre><code># List archives in the Pika-created repository
borg list /run/media/$(/usr/bin/whoami)/backup-disk/YOUR-REPO-FOLDER/YOUR-REPO-NAME
# Extract a specific archive (run from your home directory)
cd ~ && borg extract /run/media/$(/usr/bin/whoami)/backup-disk/YOUR-REPO-FOLDER/YOUR-REPO-NAME::2026-05-03-12-00-00</code></pre>
<div class="note">
<strong>Note:</strong> Pika bundles its own borg binary inside the Flatpak sandbox. However, that binary isn't accessible from the host terminal. Therefore, you must install borgbackup separately to use these commands. <code>/run/media/$(/usr/bin/whoami)/backup-disk/</code> is a placeholder for my external drive mount point; my actual mount point is <code>2TB</code>, as can be seen in Phase 2, Step 2's screenshot. Replace <code>backup-disk</code> with your actual backup location, whether that's an external drive or a folder on your host disk. Replace <code>YOUR-REPO-FOLDER</code> with your parent directory (mine was <code>SB-Backup</code>) and <code>YOUR-REPO-NAME</code> with your repository name (mine was <code>backup-legion-x144k</code>). Borg extract restores paths relative to the current working directory, so always run it from the directory you want to restore into (your home directory for Pika archives).
</div>
<div class="note">
<strong>Note:</strong> Keep borgbackup installed if you intend to follow Phases 3 and 4, which use borg commands for verification and disaster recovery. Only remove it with <code>rpm-ostree uninstall borgbackup</code> if you are certain you will rely exclusively on Pika's GUI for all backup operations and will not use the command-line procedures elsewhere in this guide.
</div>
<h2 class="phase">Phase 3: Verification</h2>
<div class="critical">
<strong>CRITICAL:</strong> A backup you've never tested is a false promise. You must verify that captured state is complete and restorable.
</div>
<h3>1. Verify package list completeness</h3>
<pre><code># Check that the package list is non-empty and contains recognizable names
/usr/bin/wc -l /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/layered-packages.txt
/usr/bin/head -n 10 /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/layered-packages.txt</code></pre>
<h3>2. Verify archive integrity</h3>
<pre><code># Test the tar archives
run0 /usr/bin/tar tzf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/etc-backup.tar.gz > /dev/null && /usr/bin/echo "etc-backup.tar.gz: OK"
run0 /usr/bin/tar tzf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/var-selective.tar.gz > /dev/null && /usr/bin/echo "var-selective.tar.gz: OK"</code></pre>
<h3>3. Verify borg archive</h3>
<div class="note">
<strong>Note:</strong> <code>/run/media/$(/usr/bin/whoami)/backup-disk/</code> is a placeholder; my actual mount point is <code>2TB</code>, as can be seen in Phase 2, Step 2's screenshot. Replace <code>backup-disk</code> with your actual backup location, whether that's an external drive or a folder on your host disk. See the Phase 2 command-line alternative for full placeholder explanations. These verification steps can also be done through Pika's GUI. Click the <strong>Archives</strong> tab to browse archive contents and confirm your files are present. The command-line procedures below are provided for users who prefer terminal verification or need to script integrity checks.
</div>
<pre><code># List archives in the repository
borg list /run/media/$(/usr/bin/whoami)/backup-disk/YOUR-REPO-FOLDER/YOUR-REPO-NAME | /usr/bin/head -n 20
# Run borg check on the repository
borg check /run/media/$(/usr/bin/whoami)/backup-disk/YOUR-REPO-FOLDER/YOUR-REPO-NAME</code></pre>
<h3>4. Document your restore procedure</h3>
<pre><code># Write a restore checklist while the setup is fresh in your memory
/usr/bin/cat > /var/home/$(/usr/bin/whoami)/secureblue-backup/RESTORE-CHECKLIST.md << 'EOF'
# Restore Checklist for secureblue-backup
## 1. Rebase to secureblue
# Example only: use the exact image reference from current-image-ref.txt
rpm-ostree rebase ostree-unverified-registry:ghcr.io/secureblue/silverblue-main-hardened:latest 2>/dev/null
systemctl reboot
## 2. Reinstall layered packages
rpm-ostree install $(/usr/bin/paste -sd' ' /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/layered-packages.txt)
systemctl reboot
## 3. Restore /etc overrides
run0 /usr/bin/tar xzpf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/etc-backup.tar.gz -C /
## 4. Restore /var state
run0 /usr/bin/tar xzpf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/var-selective.tar.gz -C /
## 5. Restore user data
# Run from your home directory
cd ~ && borg extract /run/media/$(/usr/bin/whoami)/backup-disk/YOUR-REPO-FOLDER/YOUR-REPO-NAME::YYYY-MM-DD-HH-MM-SS
## 6. Reboot and verify
systemctl reboot
EOF</code></pre>
<h2 class="phase">Phase 4: Disaster Recovery</h2>
<p>This is the full procedure for rebuilding from bare metal or a wiped disk. It assumes you've the captured state from Phases 1-3.</p>
<h3>1. Install secureblue base</h3>
<pre><code># Example: rebase to secureblue (adjust image variant to match your installation)
rpm-ostree rebase ostree-unverified-registry:ghcr.io/secureblue/silverblue-main-hardened:latest 2>/dev/null
systemctl reboot</code></pre>
<div class="note">
<strong>Note:</strong> Use the exact image reference from <code>/var/home/$(/usr/bin/whoami)/secureblue-backup/deployments/current-image-ref.txt</code> if you want the same version. Using <code>:latest</code> gets you the newest build, which may differ from your captured state. The command above uses <code>ostree-unverified-registry</code> as a disaster-recovery shortcut. For routine rebases, secureblue recommends verified pulls via cosign. See the <a href="https://secureblue.dev/">secureblue documentation</a> for the current verified rebase procedure.
</div>
<h3>2. Reinstall layered packages</h3>
<pre><code># After reboot into the new base, reinstall all layered packages
# Use the reinstall script captured in Phase 1
run0 /bin/bash /var/home/$(/usr/bin/whoami)/secureblue-backup/packages/reinstall-command.sh
# Reboot again to activate the new deployment with layered packages
systemctl reboot</code></pre>
<h3>3. Restore system configuration</h3>
<pre><code># Verify the archive doesn't contain hardware-specific files before extracting
run0 /usr/bin/tar tzf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/etc-backup.tar.gz | /usr/bin/grep -E "machine-id|hostname" || /usr/bin/echo "Verification passed: no hardware-specific files found"
# Restore /etc overrides. The --exclude flags are redundant with Phase 1 exclusions, but safe as belt-and-suspenders on new hardware.
run0 /usr/bin/tar xzpf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/etc-backup.tar.gz -C / --exclude=etc/machine-id --exclude=etc/hostname
# Restore /var state
run0 /usr/bin/tar xzpf /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/var-selective.tar.gz -C /
# Fix SELinux contexts after restoring system state
run0 /sbin/restorecon -R /etc /var
# Restore user systemd units
/usr/bin/mkdir -p ~/.config/systemd/user
/usr/bin/cp /var/home/$(/usr/bin/whoami)/secureblue-backup/configs/user-systemd/* ~/.config/systemd/user/ 2>/dev/null || true</code></pre>
<div class="note">
<strong>Note:</strong> <code>/var/lib/bluetooth</code> and <code>/var/lib/boltd</code> are hardware-specific. If you are restoring to new hardware, omit those directories from the <code>/var</code> archive or delete them after restoration.
</div>
<h3>4. Restore user data</h3>
<div class="note">
<strong>Note:</strong> <code>/run/media/$(/usr/bin/whoami)/backup-disk/</code> is a placeholder for my external drive mount point; my actual mount point is <code>2TB</code>, as can be seen in Phase 2, Step 2's screenshot. Replace <code>backup-disk</code> with your actual backup location, whether that's an external drive or a folder on your host disk. See the Phase 2 command-line alternative for full placeholder explanations. You can also restore through Pika's GUI.
</div>
<pre><code># Extract from borg backup (run from your home directory)
cd ~ && borg extract /run/media/$(/usr/bin/whoami)/backup-disk/YOUR-REPO-FOLDER/YOUR-REPO-NAME::YYYY-MM-DD-HH-MM-SS</code></pre>
<h3>5. Validate the restored system</h3>
<pre><code># Verify deployment and layered packages
/usr/bin/rpm-ostree status
# Verify /etc drift is restored (count should be non-zero and expected)
run0 /usr/bin/ostree admin config-diff | /usr/bin/wc -l
# Ensure SELinux contexts match the new deployment
run0 /sbin/restorecon -R /etc /var
# Verify services start correctly
run0 /usr/bin/systemctl --failed --no-pager
# Verify user data is present (check your own important directories)
/usr/bin/ls -la ~ | /usr/bin/head -n 10</code></pre>
<h2 class="phase">Phase 5: Automation</h2>
<div class="note">
<strong>Note:</strong> This is separate from Pika's scheduled backups in Phase 2. Pika handles your personal files; this timer captures system state that Pika cannot reach inside its sandbox.
</div>
<p>Manual backups are forgotten backups. These timers automate the capture of system state.</p>
<h3>1. Enable lingering for your user</h3>
<p>User timers require your user session to support background operation even when you are not logged in.</p>
<pre><code>/usr/bin/loginctl enable-linger x144k</code></pre>
<div class="note">
<strong>Note:</strong> Change <code>x144k</code> to your username. All remaining commands in this phase hardcode <code>x144k</code>; replace every instance with your username before executing them.
</div>
<h3>2. Create the state capture script</h3>
<pre><code># Create the local bin directory if needed
/usr/bin/mkdir -p /var/home/x144k/.local/bin
/usr/bin/cat > /var/home/x144k/.local/bin/secureblue-state-capture << 'EOF'
#!/bin/bash
set -uo pipefail
# Change x144k to your actual username
BACKUP_BASE="/var/home/x144k/secureblue-backup"
/usr/bin/mkdir -p "${BACKUP_BASE}/deployments" "${BACKUP_BASE}/packages" "${BACKUP_BASE}/system-borg"
# Initialize borg repo for system state if it doesn't exist (user-owned)
if [ ! -f "${BACKUP_BASE}/system-borg/config" ]; then
/usr/bin/borg init --encryption=none "${BACKUP_BASE}/system-borg"
fi
# Capture current deployment state
rpm-ostree status --json > "${BACKUP_BASE}/deployments/rpm-ostree-status.json" || /usr/bin/echo "Warning: failed to capture deployment status" >&2
rpm-ostree status | /usr/bin/grep -o 'ostree-[^[:space:]]*' | /usr/bin/head -n 1 > "${BACKUP_BASE}/deployments/current-image-ref.txt" || /usr/bin/echo "Warning: failed to capture image reference" >&2
# Capture layered packages (robust JSON parsing)
/usr/bin/python3 -c "import sys,json; d=json.load(sys.stdin); [print(p) for dep in d.get('deployments',[]) if dep.get('booted') for p in dep.get('requested-packages',[])]" < <(rpm-ostree status --json) > "${BACKUP_BASE}/packages/layered-packages.txt" || /usr/bin/echo "Warning: failed to capture layered packages" >&2
/usr/bin/echo "rpm-ostree install $(/usr/bin/paste -sd' ' "${BACKUP_BASE}/packages/layered-packages.txt")" > "${BACKUP_BASE}/packages/reinstall-command.sh"
/usr/bin/chmod +x "${BACKUP_BASE}/packages/reinstall-command.sh"
# Capture /etc via borg (run as root, then restore ownership so user can manage the repo)
run0 /usr/bin/borg create --compression lz4 "${BACKUP_BASE}/system-borg::etc-$(/bin/date +%Y%m%d-%H%M%S)" /etc || /usr/bin/echo "Warning: failed to capture /etc" >&2
run0 /usr/bin/chown -R x144k:x144k "${BACKUP_BASE}/system-borg" 2>/dev/null || true
/usr/bin/echo "State captured at $(/bin/date)"
EOF
/usr/bin/chmod +x /var/home/x144k/.local/bin/secureblue-state-capture</code></pre>
<h3>3. Create the user systemd timer</h3>
<pre><code># Create user systemd directory
/usr/bin/mkdir -p /var/home/x144k/.config/systemd/user
/usr/bin/cat > /var/home/x144k/.config/systemd/user/secureblue-state-capture.service << 'EOF'
[Unit]
Description=Capture secureblue system state
[Service]
Type=oneshot
ExecStart=/var/home/x144k/.local/bin/secureblue-state-capture
StandardOutput=journal
EOF
/usr/bin/cat > /var/home/x144k/.config/systemd/user/secureblue-state-capture.timer << 'EOF'
[Unit]
Description=Weekly secureblue state capture
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
EOF
/usr/bin/systemctl --user daemon-reload
/usr/bin/systemctl --user enable --now secureblue-state-capture.timer</code></pre>
<div class="note">
<strong>Note:</strong> The script hardcodes the username <code>x144k</code>. Change all instances of <code>x144k</code> in the script and service files to your username before running these commands. User timers run under your session and do not require root privileges for scheduling, though the script internally uses <code>run0</code> to back up <code>/etc</code>. To prune old borg archives and prevent unbounded growth, run <code>borg prune --keep-weekly=4 --keep-monthly=3 "${BACKUP_BASE}/system-borg"</code> periodically.
</div>
<h2 class="phase">Troubleshooting</h2>
<p>These are issues you may encounter while implementing this strategy. The fix patterns should transfer even if your exact error differs.</p>
<h3>Restored /etc files disappear after rebase</h3>
<div class="symptom"><strong>Symptom:</strong> You restored /etc from backup, but after <code>rpm-ostree rebase</code> and reboot, some files are missing or reverted.</div>
<div class="cause"><strong>Cause:</strong> rpm-ostree performs a three-way merge of /etc during deployment switches. Files that existed in the old base but not in the new base may be dropped. Files that are "unmanaged" (not tracked by any base image file) may be preserved but marked as drift.</div>
<div class="fix"><strong>Fix:</strong> After rebase and before restoring your backup, allow the system to boot once to establish the new base's /etc. Then restore your overrides on top. For critical files, use <code>ostree admin config-diff</code> to inspect what the system considers drift.</div>
<h3>Layered packages fail to reinstall</h3>
<div class="symptom"><strong>Symptom:</strong> <code>rpm-ostree install</code> fails with "package not found" or dependency conflicts.</div>
<div class="cause"><strong>Cause:</strong> The package list was captured from a different Fedora release or secureblue image version. Repositories change; packages are renamed or removed.</div>
<div class="fix"><strong>Fix:</strong> The package list is a starting point, not a sacred script. Install packages individually and skip those that no longer exist. Update your <code>layered-packages.txt</code> after each successful rebuild.</div>
<h3>/var restore breaks services</h3>
<div class="symptom"><strong>Symptom:</strong> After restoring /var, services fail to start or containers behave strangely.</div>
<div class="cause"><strong>Cause:</strong> /var contains ephemeral runtime data, SELinux labels that may not match the new deployment, and absolute paths tied to the old machine-id.</div>
<div class="fix"><strong>Fix:</strong> Be selective with /var. Never restore /var/lib/rpm-ostree, /var/tmp, or /var/run. For container storage, consider exporting and re-importing images rather than copying /var/lib/containers wholesale. Always run <code>restorecon -R /var</code> after restoring /var state.</div>
<h3>Borg repository on external drive is unreadable after rebase</h3>
<div class="symptom"><strong>Symptom:</strong> The external drive mounts with different permissions, or borg reports repository corruption.</div>
<div class="cause"><strong>Cause:</strong> Rebase changes your user UID or SELinux contexts. The drive may also mount under a different path.</div>
<div class="fix"><strong>Fix:</strong> Mount the drive and verify ownership: <code>ls -la /run/media/$USER</code>. If needed, relabel: <code>restorecon -R /run/media/$USER/backup-disk</code>. For borg specifically, ensure the repository directory is readable by your user.</div>
<h2 class="phase">Closing thoughts</h2>
<p>I built this guide because I needed it myself. Once I had layered packages, modified configs, and data scattered across /home, /etc, and /var, I realized I had no clear record of what I had changed or how to rebuild it. Snapshots help with daily mistakes, but they do not survive a dead disk. I wanted something I could hand to my future self after a hardware failure and say: follow this, and you'll be back to normal.</p>
<p>If you followed along, you now have the same thing: Pika handling your files, a captured package list, archived system configs, and a written restore procedure while it's still fresh in your mind. That last part matters more than the tools. A backup plan you've never tested is a wish, not a plan. A restore procedure you wrote down while calm is a lifeline when you are not.</p>
<p>Best of luck. Hope you never need it.</p>
</div>
</body>
</html>