Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Copies the FreeNAS settings file to a destination you specify, using a
- # filenaming scheme concatenating the hostname, FreeNAS version, and
- # current date. Strips any parentheses and replaces any spaces in the
- # resulting filename with '-' characters. Removes prior settings files
- # 90 days old or older after copying the current settings.
- # Tested with versions 9.3.x and 9.10. You must modify the DEST_DIR
- # variable below to match your desired copy destination.
- # The source FreeNAS configuration database file:
- SRC_FILE="/data/freenas-v1.db"
- # Form the destination filename - edit DEST_DIR here:
- DEST_DIR="/mnt/tank/sysadmin/config"
- DEST_HOST=$(hostname -s)
- DEST_VERSION=$(cat /etc/version | sed -e 's/ /-/' | sed -e 's/(//' | sed -e 's/)//')
- DEST_DATE=$(date +%Y%m%d%H%M%S)
- DEST_FILE="$DEST_HOST"-"$DEST_VERSION"-"$DEST_DATE".db
- echo "Backup configuration database file: $DEST_FILE"
- # Copy the source to the destination:
- cp "$SRC_FILE" "$DEST_DIR"/"$DEST_FILE"
- # Remove prior versions in the destination directory that are 90 days old or older:
- $(find "$DEST_DIR" -mtime +90 -name "*.db" -exec bash -c 'rm {}' \;)
Add Comment
Please, Sign In to add comment