diff --git a/handlers/borg.in b/handlers/borg.in index 22977cfaee10bebb493506119ec6546855818c56..2879218195404c4a2618e6585964b09e1df650c9 100644 --- a/handlers/borg.in +++ b/handlers/borg.in @@ -200,7 +200,7 @@ if [ $test = 0 ]; then fi fi -# in case of local backup, setting reop files to correct user, if user is set +# in case of local backup, setting repo files to correct user, if user is set if [ "$host" == "localhost" ] && [ -n "$user" ]; then chownstr="chown -Rf $user:$user $directory" debug "Setting appropriate files ownership" @@ -243,6 +243,24 @@ if [ "$prune" == "yes" ]; then fatal "Failed removing old backups." fi fi + + # in case of local backup, setting repo files to correct user, if user is set + if [ "$host" == "localhost" ] && [ -n "$user" ]; then + chownstr="chown -Rf $user:$user $directory" + debug "Setting appropriate files ownership" + debug "$nice $chownstr" + + if [ $test = 0 ]; then + output=`$nice su -c "$chownstr" 2>&1` + if [ $? = 0 ]; then + debug $output + info "Successfully changed repo user to $user" + else + error $output + warning "Failed to change repo user. Files ownership may be stuck to root" + fi + fi + fi fi debug "unset BORG_PASSPHRASE"