This script searches through a directory of ZIP archives, looks for a specific zone file inside each archive,
and extracts the matching files into a _working/ subdirectory.
Each extracted file is renamed to include both the original zone file name and the archive it came from.
./zone_from_zips.sh <zip_dir> <zone_file_name><zip_dir>→ Path to the directory containing ZIP archives<zone_file_name>→ Exact filename to extract (e.g.db.example.com)
Example:
./zone_from_zips.sh ./exports db.example.com- Processes all
.zipor.ZIPfiles in the given directory (top-level only). - Extracts only the specified
<zone_file_name>from each archive. - Saves results in:
<zip_dir>/_working/ - Renames extracted files to:
Example:
<zone_file_name>_<archive_basename>db.example.com_backup1.zip→db.example.com_backup1.
- Extracted files:
<zip_dir>/_working/<zone_file_name>_<archive-name> - Console log:
- Reports each archive processed
- Indicates whether the zone file was found
- Bash
unzip
- If no
.zipfiles are found, the script exits with an error. - Only files in the top level of
<zip_dir>are processed (not recursive). - Existing
_working/directory will be reused (files may be overwritten).
This script is covered under the repository’s main MIT License.