From e3f66a6dc8a43d22dc5a4c4f498085b7c949cb0e Mon Sep 17 00:00:00 2001 From: Kelvin Jasperson Date: Fri, 17 Aug 2018 18:17:10 -0600 Subject: [PATCH] Ability to change backup destination --- README.md | 1 + pfsense-backup.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d8d8fb7..e2974c4 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ docker run --detach --volume $(pwd):/data --env PFSENSE_USER=backupuser --env PF - `PFSENSE_SCHEME` Required. Should either be `http` or `https`. This parameter is not validated. - `PFSENSE_CRON_SCHEDULE` Optional. The cron schedule to use, should contain 5 items separated by spaces. This parameter is not validated. No default. - `PFSENSE_BACK_UP_RRD_DATA`. Optional. Should be either 1 or 0. This parameters is not validated. Include RRD data in the backup? 1=yes, 0=no. Default=1. +- `PFSENSE_BACKUP_DESTINATION_DIR`. Optional. What is the destination directory to back up to. This directory must exist and be writable. Default=/data ## Help! - Is the username correct? diff --git a/pfsense-backup.sh b/pfsense-backup.sh index 932f9fb..ea41b02 100755 --- a/pfsense-backup.sh +++ b/pfsense-backup.sh @@ -16,10 +16,10 @@ function do_backup() wget --keep-session-cookies --load-cookies cookies.txt --no-check-certificate \ --post-data "download=download${getrrd}&__csrf_magic=$(head -n 1 csrf2.txt)" \ - ${url}/diag_backup.php -q -O /data/config-${PFSENSE_IP}-${timestamp}.xml + ${url}/diag_backup.php -q -O ${destination}/config-${PFSENSE_IP}-${timestamp}.xml return_value=$? if [ $return_value -eq 0 ]; then - echo "Backup saved as config-${PFSENSE_IP}-${timestamp}.xml" + echo "Backup saved as ${destination}/config-${PFSENSE_IP}-${timestamp}.xml" else echo "Backup failed" exit 1 @@ -48,6 +48,11 @@ else getrrd="" fi fi +if [ -z "$PFSENSE_BACKUP_DESTINATION_DIR" ]; then + destination="/data" +else + destination="$PFSENSE_BACKUP_DESTINATION_DIR" +fi # set up variables url=${PFSENSE_SCHEME}://${PFSENSE_IP}