mirror of
https://github.com/Spearfoot/FreeNAS-scripts
synced 2025-12-06 01:23:19 +00:00
35 lines
1.0 KiB
Bash
35 lines
1.0 KiB
Bash
#!/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}"
|