1. Knowledge Base
  2. Restore Operations

How to restore Zmanda backups from Tapes using 'dd' command

Restoring backups written to tapes is a critical part of data recovery and disaster preparedness. This user guide outlines the steps to restore Zmanda tape backups using the 'dd' command-line tool available in most Linux distributions.

Prerequisites

Make sure you have the following setup before you start the restoration process:

  1. Required Utilities Installed: The following commands or utilities should be installed on the Linux server where you are attempting the restore.

  • dd

  • gpg

  • tar

  • mt-st

  • mtx

  • lsscsi

2. Empty Directory with Sufficient Space: Create a new empty directory on the server where you have enough space to accommodate the restored backup data.

3. Connected Tape Drive: Ensure that the changer or tape library must be connected to the server where the restore is being attempted.

4. Backup Copy of .am_passphrase File: To enable the restore, you must have a backup copy of the .am_passphrase file. This file is necessary to decrypt encrypted backups. The passkey is stored in a hidden file named .am_passphrase located in the /var/lib/amanda/ directory.

The key is present in both server and client, and depending on where you perform the encryption, the corresponding key needs to be used for decryption. Ensure you use the correct file for decrypting.

5. Secure Storage of .am_passphrase Backup: Back up the .am_passphrase file separately in a secure location, as it is required for decrypting encrypted backups. Without this file, the restore will not work.

Steps to Restore Backups from Tapes

Follow these steps to restore backups from tapes:

Step 1: Identify Backup Tapes

Navigate to the backup report using the specified email address on Zmanda Management Console (ZMC) console. The tapes utilized for each backup will be listed at the end of the backup report.

image-20231103-035439

Note: In the event of a disaster resulting in the loss of Zmanda configuration, tape information may become inaccessible. We strongly advise maintaining a separate record that includes details of the tapes used for each backup run.

Step 2: Load Tape into Tape Drive:

  • Determine the changer device using the lsscsi -g command.

image-20231103-035514

  • Check the status of the changer using mtx -f /dev/sg11 status command. This will display your tape drives and tapes.

image-20231103-035554

  • Load a tape into the drive, use the mtx command with the load option using the command mtx -f /dev/sg11 load 1 0 where 1 is the slot number and 0 is the tape drive number.

image-20231103-035623

Note: Similarly, to unload a tape from the drive, use mtx along with the unload option.

image-20231103-035701

Step 3: Rewind the Tape

  • Use the mt -f /dev/st0 rewind command to rewind the tape to the first block.

image-20231103-035738

Step 4: Skip to the Beginning of the Second File

  • The first block on the tape includes Amanda header information. To skip to the beginning of the second file, use the fsf (forward space files) option. Use the mt -f /dev/nst0 fsf 1 command to skip to the beginning of the second file.

image-20231103-035809

Step 5: Performing the Restore

Use the dd command to perform the actual restore, depending on the backup type:

For normal backups without encryption or compression:

dd if=/dev/nst0 bs=32k skip=1 | tar xvf -

For compressed backups:

dd if=/dev/nst0 bs=32k skip=1 | tar xzvf -

For encrypted backups, provide the path to the .am_passphrase file:

dd if=/dev/nst0 bs=32k skip=1 | gpg --batch --no-permission-warning --no-tty --quiet --passphrase-fd 3 --decrypt --ignore-mdc-error 3<"path/to/passphrase_file" | tar xvf -

Note: If the dd command fails for any reason, repeat steps 3 and 4 before reattempting the restore.

By following these steps, you can successfully restore backups written to tapes using Zmanda. It's essential to maintain the prerequisites and carefully execute each step to ensure a smooth restoration process.