[ -b "$partition" ] \
|| errlog "partition $partition not found" \
|| return $?
- infolog "mount partition $partition"
local backup_path=$(cat config.yaml \
| yq --raw-output ".backup_path")
- [ "$backup_path" == "null" ] \
+ [ "$backup_path" != "null" ] \
|| errlog "config.yaml backup path missing" \
|| return $?
- infolog "backup path $backup_path"
+ infolog "create backup path $backup_path"
mkdir --parents "$backup_path" \
|| errlog "could not create directory $backup_path" \
|| return $?
+ infolog "mount partition $partition to $backup_path"
mount "$partition" "$backup_path" \
|| errlog "cloud not mount $partition to $backup_path" \
|| return $?
partition_mount "$media" || return $?
}
-mount()
+mount_backup()
{
local medias=$(cat config.yaml \
| yq --raw-output '.media | keys[]')
errlog "no device was mounted"
}
-umount()
+remote_backup_dir()
+{
+ infolog "remove backup path $backup_path"
+ rmdir "$backup_path" \
+ || errlog "clound not remote $backup_path" \
+ || return $?
+}
+
+umount_backup()
{
local backup_path=$(cat config.yaml \
| yq --raw-output ".backup_path")
- [ "$backup_path" == "null" ] \
+ [ "$backup_path" != "null" ] \
|| errlog "config.yaml backup path missing" \
|| return $?
|| 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 ".backup_volume")
[ "$volume" != "null" ] \
|| return $?
if [ "$cmd" == "mount" ]; then
- mount || return $?
+ mount_backup || return $?
elif [ "$cmd" == "umount" ]; then
- umount || return $?
+ umount_backup || return $?
else
errlog "unknown command" || return $?
fi