From 3da04c1f8187ef4beecdf1718a8621ef749da406 Mon Sep 17 00:00:00 2001 From: Keith Nash Date: Wed, 15 Mar 2017 22:38:31 -0500 Subject: [PATCH] Original version --- save-config.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 save-config.sh diff --git a/save-config.sh b/save-config.sh new file mode 100644 index 0000000..469fd76 --- /dev/null +++ b/save-config.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +################################################# +# Backup the FreeNAS configuration file +################################################# + +# Specify the dataset on your system where you want the configuration files copied. +# Don't include the trailing slash. + +# Example: configdir=/mnt/tank/sysadmin/config + +configdir= + +# Remove this code once you've defined configdir above... :-) + +if [ -z ${configdir} ]; then + echo "Edit script and specify the target directory ('configdir') before using $0" + exit 2 +fi + +freenashost=$(hostname -s) + +fnconfigdest_version=$(cat /etc/version) +fnconfigdest_version="${fnconfigdest_version//(/}" +fnconfigdest_version="${fnconfigdest_version//)/}" +fnconfigdest_version="${fnconfigdest_version// /-}" +fnconfigdest_date=$(date +%Y%m%d%H%M%S) +fnconfigdest="${configdir}"/"${freenashost}"-"${fnconfigdest_version}"-"${fnconfigdest_date}".db + +echo "Backup configuration database file: ${fnconfigdest}" + +# Copy the source to the destination: + +cp /data/freenas-v1.db "${fnconfigdest}"