NetWorker: Using the scanner utility
Summary: This article describes various use cases for the scanner tool and general usage best practices and caveats.
Instructions
- Creating a list of all savesets found on the volume file system
- Importing a foreign or deleted volume back into the media database
- Reading a saveset to rebuild index entries from the data itself, where the browse period has passed
- Correcting entries for one or more savesets on a volume if media database records are incorrect
- Directly reading saveset data to a local file for separate uasm recovery, especially for damaged or incomplete savesets
Verifying volume label and contents
Scanner's default usage when not including any other arguments can be used to report the label, volume ID, block size for tape media, and what saveset entities exist on a volume. While no -i / -m is present, no database records are modified. This can be useful to verify presence of a disk or tape saveset by checking the media itself; It can also determine if there is a viable, readable label - for example, scanner may reveal tape encryption prevents a label read (See LTO Hardware Encryption and NetWorker for more details), presenting the error:
8945:scanner: read: -1 bytes
It may also reveal SCSI resets for tape-class devices (Troubleshooting Overwritten Labels and SCSI Resets in NetWorker), where mount fails:
Unexpected file number, wanted 2, got <other number>
Example:
scanner device_name_or_local_path
Importing volumes and records
Example:
scanner -m device_name_or_local_path
Re-indexing savesets for browse
Example:
scanner -i -F device_name_or_local_path
Forcing saveset metadata correction
If a saveset already exists in the database when scanner finds it, the default behavior is to forgo update, for performance reasons. Where entries in the media database are considered to be missing or incomplete/corrupted, or -i is being used to re-index a saveset past its browse period, use -F to force overwrite of the record information; otherwise, deletion of the saveset isrequired first. Note that unless a new retention time is specified (see below) using -y, the new instance retention is calculated automatically. Note as well this flag is required when scanning tape media.
Example:
scanner -m -F device_name_or_local_path
Scanning saveset contents to local file
Sometimes, for savesets which require special handling, such as tape savesets with bad spots, scanner can be used to directly read the data and instead of updating media database entries, commit the data to a monolithic file which can then be recovered with the uasm utility. This can be a useful last resort where typical recoveries prove impossible. To scan a saveset to file, specify a single saveset only with -S and redirect the output. Note that data output on stdout, and log messages on stderr - if both are redirected to the data file, it is unusable. Ensure that stderr is redirected elsewhere appropriately. See NetWorker: Using uasm for save and recovery for details how to recover from the scanned saveset file.
Example:
scanner -S saveset_id > scanned_saveset_filename 2> scanner_log
Selectively scanning a volume
There are several ways to scan a volume for specific entries:- Individual savesets: Use -S saveset_id one or more times to scan only for those savesets; can be used instead of or with -I saveset_id_listfile which will also restrict checking for savesets in the file (one per line).
- Bootstraps: To scan for bootstrap savesets only - run scanner with the -B switch. Note that there is no need to use -m / -i or -F since bootstraps are not required to be in the media database to recover - their location and saveset ID are all that are required for nsrdr disaster recovery.
- Creation time range: Use -Y for creation start / later-than datetime (for example 2023/01/01) and -Z for creation end / earlier than datetime (for example 2024/02/29) to restrict to savesets created within a specific time period only.
- Client / saveset name: Use either or both of -c client or -N saveset_name to scan only for savesets matching these criteria; -m or -i is required for -c. Either switch can be used multiple times to match multiple criteria.
Best practices when scanning tape volumes
The scanner utility is low level and not represented at all in the UI, nor handled in normal NetWorker operations. As a result, it is important to ensure that tape devices are protected from interference, since the NetWorker server is not aware of scanner's operation, and may request the tape or the drive. To avoid this,
- Load the tape cartridge in an empty drive without mounting from the UI in the library / drive context menu.
- Mark the tape device as 'Disabled' or 'Service Mode' to avoid NetWorker attempting to do anything with either drive or media.
- Begin the scanner command and allow it to complete.
- When finished, re-enable the tape drive, and unload the tape media.