We need root access to copy backup files with the filesystem backend

This commit is contained in:
Johannes Zellner
2017-04-14 15:49:42 +02:00
parent b29a6014d5
commit 5e1ad4ad93
5 changed files with 47 additions and 19 deletions

27
src/scripts/cpbackup.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
# This is part of the storage/filesystem backend!
set -eu -o pipefail
if [[ ${EUID} -ne 0 ]]; then
echo "This script should be run as root." > /dev/stderr
exit 1
fi
if [[ $# == 1 && "$1" == "--check" ]]; then
echo "OK"
exit 0
fi
if [[ $# -lt 2 ]]; then
echo "Usage: cpbackup.sh <source> <destination>"
exit 1
fi
# ensure destination path
readonly DEST_PATH=$(dirname "${2}")
mkdir -p "${DEST_PATH}"
# copy the file
cp "${1}" "${2}"