From 3e38406bd0d93864cf26714f4a3b4002dd6aa046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20G=C3=A9linat?= <jerome.gelinat@jipem.net> Date: Mon, 13 Dec 2021 23:28:26 +0000 Subject: [PATCH] Borg - Allow setting files ownership in case of local backup Set file ownership after creating backup (for whole depot). Assuming that group name is same name as user. --- handlers/borg.in | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/handlers/borg.in b/handlers/borg.in index 582e0a6..22977cf 100644 --- a/handlers/borg.in +++ b/handlers/borg.in @@ -200,6 +200,25 @@ if [ $test = 0 ]; then fi fi +# in case of local backup, setting reop 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 + + ### REMOVE OLD BACKUPS ### # borg prune -- GitLab