2021-01-21 13:58:30 -08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Bashup - A set of bash scripts for managing backups.
|
|
|
|
# https://git.stack-source.com/msb/bashup
|
|
|
|
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
|
|
|
|
2021-04-22 15:03:50 -07:00
|
|
|
# load include file
|
|
|
|
source $(dirname $0)/bashup.sh
|
2021-01-21 13:58:30 -08:00
|
|
|
|
2021-04-23 09:49:36 -07:00
|
|
|
bashup::set-retention_array
|
2021-01-21 13:58:30 -08:00
|
|
|
|
|
|
|
# create backup for today
|
|
|
|
if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then
|
|
|
|
|
|
|
|
# create backup (date) dir if it doesn't already exist
|
|
|
|
if [ ! -d "$backup_storage_dir/$today" ]; then
|
|
|
|
|
|
|
|
mkdir $backup_storage_dir/$today
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# only proceed if pdns zones have not already been backed up
|
|
|
|
if [[ ! -d $backup_storage_dir/$today/pdns ]]; then
|
|
|
|
|
|
|
|
mkdir $backup_storage_dir/$today/pdns
|
|
|
|
|
|
|
|
zones=(`/usr/bin/pdnsutil list-all-zones`)
|
|
|
|
|
|
|
|
for zone in "${zones[@]}"; do
|
|
|
|
|
|
|
|
/usr/bin/pdnsutil list-zone $zone > "$backup_storage_dir/$today/pdns/$zone.zone"
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2021-04-23 12:52:28 -07:00
|
|
|
bashup::remove_expired_backups pdns
|
2021-04-22 15:03:50 -07:00
|
|
|
bashup::unmount_storage_dir
|
2021-01-21 13:58:30 -08:00
|
|
|
|
2021-04-22 15:03:50 -07:00
|
|
|
exit 0
|