From: Bastian Dehn Date: Sun, 25 May 2025 07:13:26 +0000 (+0200) Subject: add umount volume X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=4bbb066ffe85b2ffc35ffdb2a03ce19779779e9b;p=simple-backup.git add umount volume --- diff --git a/backupmount b/backupmount index a1e5e28..bb8ab25 100755 --- a/backupmount +++ b/backupmount @@ -64,7 +64,7 @@ device_mount() || return $? infolog "use key $key" local volume=$(cat "config.yaml" \ - | yq --raw-output ".media.\"$media\".volume") + | yq --raw-output ".media.volume") [ "$volume" != "null" ] \ || errlog "config.yaml volume for $media missing" \ || return $? @@ -102,6 +102,38 @@ mount() errlog "no device was mounted" } +umount() +{ + + local backup_path=$(cat config.yaml \ + | yq --raw-output ".backup_path") + [ "$backup_path" == "null" ] \ + || errlog "config.yaml backup path missing" + || return $? + + infolog "umount backup path $backup_path" + umount "$backup_path" \ + || errlog "could not unmount $backup_path" \ + || return $? + + infolog "remove backup path $backup_path" + rmdir --parents "$backup_path" \ + || errlog "clound not remote $backup_path" \ + || return $? + + infolog "close volume" + local volume=$(cat "config.yaml" \ + | yq --raw-output ".media.volume") + [ "$volume" != "null" ] \ + || errlog "config.yaml volume for $media missing" \ + || return $? + + infolog "close volume $volume" + cryptsetup close "$volume" \ + || errlog "could not close $volume" \ + || return $? +} + main() { local cmd="$1" @@ -121,7 +153,7 @@ main() if [ "$cmd" == "mount" ]; then mount || return $? elif [ "$cmd" == "umount" ]; then - echo "umount" + umount || return $? else errlog "unknown command" || return $? fi