Diff
1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
2index 0cd5a002b64b9b47fae54619c3f1d76b1df0bd7b..6f27460d5fc0caa5b09b759ecc935174bae1a710 100644
3--- a/duplicity-backup.conf.example
4+++ b/duplicity-backup.conf.example
5@@ -233,13 +233,16 @@ CLEAN_UP_VARIABLE="4"
6 #REMOVE_INCREMENTALS_OLDER_THAN="4"
7
8 # LOGFILE INFORMATION DIRECTORY
9-# Provide directory for logfile, ownership of logfile, and verbosity level.
10+# Provide directory for logfile, ownership of logfile & directory, and verbosity level.
11 # I run this script as root, but save the log files under my user name --
12 # just makes it easier for me to read them and delete them as needed.
13
14 LOGDIR="/home/foobar_user_name/logs/test2/"
15 LOG_FILE="duplicity-`date +%Y-%m-%d_%H-%M`.txt"
16 LOG_FILE_OWNER="foobar_user_name:foobar_user_name"
17+# Note that if the configured LOGDIR does not exist it will be created
18+# and its owner:group set to that of the configured LOG_FILE_OWNER.
19+# If the configured LOGDIR already exists no change to owner:group is attempted.
20 #REMOVE_LOGS_OLDER_THAN='30' # (days) uncomment to activate
21 VERBOSITY="-v3"
22
23diff --git a/duplicity-backup.sh b/duplicity-backup.sh
24index 745e635140e8b20310dc26a6aab22c53816d651d..af888002aba24f6f45f119859f3cfba27bcfceac 100755
25--- a/duplicity-backup.sh
26+++ b/duplicity-backup.sh
27@@ -281,6 +281,14 @@ check_logdir()
28 else
29 echo "Directory ${LOGDIR} successfully created."
30 fi
31+ echo "Attempting to change owner:group of ${LOGDIR} to ${LOG_FILE_OWNER} ..."
32+ if ! chown ${LOG_FILE_OWNER} ${LOGDIR}; then
33+ echo "User ${USER} could not change the owner:group of ${LOGDIR} to $LOG_FILE_OWNER"
34+ echo "Aborting..."
35+ exit 1
36+ else
37+ echo "Directory ${LOGDIR} successfully changed to owner:group of ${LOG_FILE_OWNER}"
38+ fi
39 elif [ ! -w ${LOGDIR} ]; then
40 echo "Log directory ${LOGDIR} is not writeable by this user: ${USER}"
41 echo "Aborting..."