2016-10-10 14:01:09 +02:00
|
|
|
---
|
2021-03-13 19:06:18 +01:00
|
|
|
lang: en
|
2016-10-10 14:01:09 +02:00
|
|
|
layout: doc
|
2021-06-16 19:56:25 -07:00
|
|
|
permalink: /doc/backup-emergency-restore-v4/
|
2016-10-10 14:01:09 +02:00
|
|
|
redirect_from:
|
|
|
|
- /en/doc/backup-emergency-restore-v4/
|
|
|
|
- /doc/BackupEmergencyRestoreV4/
|
2021-03-13 19:06:18 +01:00
|
|
|
ref: 192
|
2021-07-09 01:06:41 +00:00
|
|
|
title: Emergency backup recovery (v4)
|
2016-10-10 14:01:09 +02:00
|
|
|
---
|
|
|
|
|
2018-06-30 21:01:18 -05:00
|
|
|
This page describes how to perform an emergency restore of a backup created on
|
2018-07-01 18:53:47 -05:00
|
|
|
Qubes R4.X (which uses backup format version 4).
|
2018-06-30 21:01:18 -05:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
The Qubes backup system is designed with emergency disaster recovery in mind. No
|
|
|
|
special Qubes-specific tools are required to access data backed up by Qubes. In
|
|
|
|
the event a Qubes system is unavailable, you can access your data on any
|
|
|
|
GNU/Linux system by following the instructions on this page.
|
2018-06-30 21:01:18 -05:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
**Important:** You may wish to store a copy of these instructions with your
|
|
|
|
Qubes backups. All Qubes documentation, including this page, is available in
|
2022-11-23 17:53:29 -08:00
|
|
|
plain text format in the [qubes-doc](https://github.com/QubesOS/qubes-doc) Git
|
|
|
|
repository.
|
2022-11-23 17:34:08 -08:00
|
|
|
|
|
|
|
## Required `scrypt` utility
|
2018-07-01 18:53:47 -05:00
|
|
|
|
2021-06-18 06:25:06 -07:00
|
|
|
In Qubes 4.X, backups are encrypted and integrity-protected with
|
|
|
|
[scrypt](https://www.tarsnap.com/scrypt.html). You will need a copy of this
|
|
|
|
utility in order to access your data. Since `scrypt` is not pre-installed on
|
|
|
|
every GNU/Linux system, it is strongly recommended that you store a copy of it
|
|
|
|
with your backups. If your distribution has `scrypt` packaged (e.g., Debian),
|
|
|
|
you can install the package in the standard way using your distribution's
|
|
|
|
package manager. Otherwise, you'll need to obtain a compiled binary
|
|
|
|
(instructions below) or compile the program from source yourself. (Don't forget
|
|
|
|
to [verify signatures](/security/verifying-signatures) first!) Note that
|
|
|
|
versions of `scrypt` up to 1.2.0 (inclusive) do not support the `-P` option for
|
|
|
|
easier scripting, which means you'll need to enter the passphrase for each file
|
2018-07-01 18:53:47 -05:00
|
|
|
separately, instead of using `echo ... | scrypt`.
|
|
|
|
|
|
|
|
Here are instructions for obtaining a compiled `scrypt` binary. This example
|
2022-11-23 17:34:08 -08:00
|
|
|
uses an RPM-based system (Fedora), but the same general procedure should work on
|
|
|
|
any GNU/Linux system.
|
2018-07-01 18:53:47 -05:00
|
|
|
|
2021-07-20 03:27:51 -07:00
|
|
|
1. If you're not on Qubes 4.X, [import and authenticate the Release 4 Signing
|
|
|
|
Key](/security/verifying-signatures/#how-to-import-and-authenticate-release-signing-keys).
|
2018-07-01 18:53:47 -05:00
|
|
|
|
|
|
|
[user@restore ~]$ sudo rpm --import qubes-release-4-signing-key.asc
|
|
|
|
|
2021-07-20 03:27:51 -07:00
|
|
|
2. Download the `scrypt` RPM.
|
2018-07-01 18:53:47 -05:00
|
|
|
|
|
|
|
[user@restore ~]$ dnf download scrypt
|
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
Or, if that doesn't work:
|
2018-07-01 18:53:47 -05:00
|
|
|
|
|
|
|
[user@restore ~]$ curl -O https://yum.qubes-os.org/r4.0/current/vm/fc28/rpm/scrypt-1.2.1-1.fc28.x86_64.rpm
|
|
|
|
|
2021-07-20 03:27:51 -07:00
|
|
|
3. Verify the signature on the `scrypt` RPM.
|
2018-07-01 18:53:47 -05:00
|
|
|
|
2021-03-13 18:03:23 +01:00
|
|
|
[user@restore ~]$ rpm -K scrypt-*.rpm
|
2018-07-01 18:53:47 -05:00
|
|
|
scrypt-*.rpm: digests signatures OK
|
|
|
|
|
|
|
|
The message `digests signatures OK` means that both the digest (i.e., the
|
|
|
|
output of a hash function) and PGP signature verification were successful.
|
|
|
|
|
2021-07-20 03:27:51 -07:00
|
|
|
4. Install `rpmdevtools`.
|
2018-07-01 18:53:47 -05:00
|
|
|
|
|
|
|
[user@restore ~]$ sudo dnf install rpmdevtools
|
|
|
|
|
2021-07-20 03:27:51 -07:00
|
|
|
5. Extract the `scrypt` binary from the RPM.
|
2018-07-01 18:53:47 -05:00
|
|
|
|
|
|
|
[user@restore ~]$ rpmdev-extract scrypt-*.rpm
|
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
## Emergency recovery instructions
|
2018-06-30 21:01:18 -05:00
|
|
|
|
|
|
|
**Note:** In the following example, the backup file is both *encrypted* and
|
|
|
|
*compressed*.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
1. (Optional) If you're working with binaries that you saved with your backup,
|
2023-04-11 16:42:34 -07:00
|
|
|
such as `scrypt`, you can make things easier by aliasing those binaries now,
|
|
|
|
e.g.,
|
2022-11-23 17:34:08 -08:00
|
|
|
|
2023-04-11 16:35:19 -07:00
|
|
|
[user@restore ~]$ alias scrypt="$PWD/scrypt-*/usr/bin/scrypt"
|
2022-11-23 17:34:08 -08:00
|
|
|
|
|
|
|
2. Untar the main backup file.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
|
|
|
[user@restore ~]$ tar -i -xvf qubes-backup-2015-06-05T123456
|
|
|
|
backup-header
|
|
|
|
backup-header.hmac
|
|
|
|
qubes.xml.000.enc
|
|
|
|
vm1/private.img.000.enc
|
|
|
|
vm1/private.img.001.enc
|
|
|
|
vm1/private.img.002.enc
|
|
|
|
vm1/icon.png.000.enc
|
|
|
|
vm1/firewall.xml.000.enc
|
|
|
|
vm1/whitelisted-appmenus.list.000.enc
|
|
|
|
dom0-home/dom0user.000.enc
|
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
3. Set the backup passphrase environment variable. While this isn't strictly
|
|
|
|
required, it will be handy later and will avoid saving the passphrase in the
|
|
|
|
shell's history.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2022-01-02 13:05:47 +00:00
|
|
|
[user@restore ~]$ read -r backup_pass
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
4. Verify the integrity of `backup-header`. For compatibility reasons,
|
|
|
|
`backup-header.hmac` is an encrypted *and integrity protected* version of
|
|
|
|
`backup-header`.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2018-05-06 12:20:14 +01:00
|
|
|
[user@restore ~]$ set +H
|
2016-10-10 14:01:09 +02:00
|
|
|
[user@restore ~]$ echo "backup-header!$backup_pass" |\
|
2018-05-06 12:20:14 +01:00
|
|
|
scrypt dec -P backup-header.hmac backup-header.verified && \
|
2016-10-10 14:01:09 +02:00
|
|
|
diff -qs backup-header backup-header.verified
|
|
|
|
Files backup-header and backup-header.verified are identical
|
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
**Note:** If this command fails, it may be that the backup was tampered with
|
|
|
|
or is in a different format. In the latter case, look inside `backup-header`
|
|
|
|
at the `version` field. If it contains a value other than `version=4`, go to
|
|
|
|
the instructions for that format version:
|
2021-04-11 00:09:05 +02:00
|
|
|
- [Emergency Backup Recovery without Qubes (v2)](/doc/backup-emergency-restore-v2/)
|
|
|
|
- [Emergency Backup Recovery without Qubes (v3)](/doc/backup-emergency-restore-v3/)
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
5. Read `backup-header`.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
|
|
|
[user@restore ~]$ cat backup-header
|
|
|
|
version=4
|
|
|
|
encrypted=True
|
|
|
|
compressed=True
|
|
|
|
compression-filter=gzip
|
2022-11-23 17:34:08 -08:00
|
|
|
hmac-algorithm=scrypt
|
|
|
|
backup-id=20161020T123455-1234
|
2018-07-01 18:53:47 -05:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
6. Set `backup_id` to the value in the last line of `backup-header`. (Note that
|
|
|
|
there is a hyphen in `backup-id` in the file, whereas there is an underscore
|
|
|
|
in `backup_id` in the variable you're setting.)
|
2018-07-01 18:53:47 -05:00
|
|
|
|
|
|
|
[user@restore ~]$ backup_id=20161020T123455-1234
|
|
|
|
|
2022-11-23 17:55:04 -08:00
|
|
|
7. Choose a qube whose data you wish to restore (in this example, `vm1`).
|
|
|
|
Verify the data's integrity, decrypt it, decompress it, and extract it.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2020-10-08 15:22:54 +00:00
|
|
|
[user@restore ~]$ find vm1 -name 'private.img.*.enc' | sort -V | while read f_enc; do \
|
2016-10-10 14:01:09 +02:00
|
|
|
f_dec=${f_enc%.enc}; \
|
2020-10-09 11:07:48 +00:00
|
|
|
echo "$backup_id!$f_dec!$backup_pass" | scrypt dec -P $f_enc || break; \
|
|
|
|
done | gzip -d | tar -xv
|
2016-10-10 14:01:09 +02:00
|
|
|
vm1/private.img
|
|
|
|
|
2020-10-09 11:07:48 +00:00
|
|
|
If this pipeline fails, it is likely that the backup is corrupted or has
|
|
|
|
been tampered with.
|
|
|
|
|
2018-06-30 21:01:18 -05:00
|
|
|
**Note:** If your backup was compressed with a program other than `gzip`,
|
2020-10-09 06:29:27 -05:00
|
|
|
you must substitute the correct compression program in the command above.
|
2022-11-23 17:34:08 -08:00
|
|
|
This information is contained in `backup-header` (see step 5). For example,
|
|
|
|
if your backup is compressed with `bzip2`, use `bzip2 -d` instead of `gzip
|
|
|
|
-d` in the command above.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
8. Enter the decrypted directory, mount `private.img`, and access your data.
|
2016-10-10 14:01:09 +02:00
|
|
|
|
2023-04-11 16:42:34 -07:00
|
|
|
[user@restore]$ sudo mkdir /mnt/img
|
|
|
|
[user@restore]$ sudo mount -o loop vm1/private.img /mnt/img/
|
|
|
|
[user@restore]$ cat /mnt/img/home/user/your_data.txt
|
2016-10-10 14:01:09 +02:00
|
|
|
This data has been successfully recovered!
|
|
|
|
|
2022-11-23 17:34:08 -08:00
|
|
|
Success! If you wish to recover data from more than one qube in your backup,
|
|
|
|
simply repeat steps 7 and 8 for each additional qube.
|