borg-mount-archiv.sh: print out the commans used to ,ount archive.

This commit is contained in:
Christoph 2024-12-31 18:46:33 +01:00
parent 2d6485f06c
commit d85ce20eba

View File

@ -268,24 +268,26 @@ export BORG_RSH
BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
export BORG_RELOCATED_REPO_ACCESS_IS_OK
echononl "Create Restore Directory '${BORG_FUSE_MOUNT_DIR}'."
if [ ! -d "${BORG_FUSE_MOUNT_DIR}" ]; then
mkdir -p "${BORG_FUSE_MOUNT_DIR}" > ${log_file} 2>&1
if [[ $? -gt 0 ]] ; then
echo_failed
error "$(cat "${log_file}")"
blank_line
fatal "No restore directory '${BORG_FUSE_MOUNT_DIR}' present!"
else
echo_ok
fi
else
echo_skipped
LIST_OF_FILES_OR_DIRECTORIES=
echo -e "\033[32m--\033[m"
echo ""
echo "Specify a space-separated list of files or directories to be part of the mounted filesystem."
echo ""
echo -e " Type \"\033[33mall\033[m\" or leave emty to mount the full archive"
echo ""
echononl "List of files or directories: "
read LIST_OF_FILES_OR_DIRECTORIES
if [[ "X${LIST_OF_FILES_OR_DIRECTORIES}" = "X" ]] || [[ "$(trim ${LIST_OF_FILES_OR_DIRECTORIES,,})" = 'all' ]] ; then
LIST_OF_FILES_OR_DIRECTORIES=""
fi
blank_line
echo -e "\033[32m--\033[m"
echo ""
# List Borg Backups
#
@ -306,9 +308,173 @@ read BORG_BACKUP_ID
echo -e " \033[33m--------------------------------------------\033[m"
echo ""
echononl "Mount archive '${BORG_REPO}::${BORG_BACKUP_ID}' to '${BORG_FUSE_MOUNT_DIR}'.."
blank_line
borg mount ${BORG_URL}::${BORG_BACKUP_ID} ${BORG_FUSE_MOUNT_DIR} >> "${log_file}" 2>&1
echo ""
echo ""
echo -e "\t\033[32mStart script for (readonly) mounting repository archiv '${BORG_BACKUP_ID}'..\033[m"
echo ""
echo -e "\tBORG_HOST......................: ${BORG_HOST}"
echo -e "\tBORG_REPO......................: ${BORG_REPO}"
echo ""
echo -e "\tBORG_PASSPHRASE................: ${BORG_PASSPHRASE}"
echo ""
echo -e "\tSSH_USER ......................: ${SSH_USER}"
echo -e "\tSSH_PORT.......................: ${SSH_PORT}"
echo -e "\tBORG_RSH.......................: ${BORG_RSH}"
echo ""
echo -e "\tBORG_URL.......................: ${BORG_URL}"
echo ""
echo -e "\tBORG_FUSE_MOUNT_DIR............: ${BORG_FUSE_MOUNT_DIR}"
if [[ -z "${LIST_OF_FILES_OR_DIRECTORIES}" ]]; then
echo -e "\tLIST_OF_FILES_OR_DIRECTORIES...: \033[33mMount the full archive\033[m"
else
echo -e "\tLIST_OF_FILES_OR_DIRECTORIES...: ${LIST_OF_FILES_OR_DIRECTORIES}"
fi
echo ""
echo ""
declare -i _CHOOSE
echo -e " Ho to continue?"
echo ""
echo -e " \033[1m[1] Mount files from repository $(basename "${BORG_REPO}") archive ${BORG_BACKUP_ID}\033[m"
echo -e " [2] Only print out the commands for mounting files/folders"
echo -e " [3] Exit borg2 mount script."
echo ""
echo " Type a number or press <RETURN> to choose highlighted value"
echo ""
echononl "Eingabe: "
while [[ -z "${_CHOOSE}" ]]; do
read OPTION
[[ -z "$OPTION" ]] && OPTION=1
case $OPTION in
1) _CHOOSE=1
;;
2) _CHOOSE=2
;;
3) _CHOOSE=3
;;
*)
echo ""
echo -e "\tFalsche Eingabe ! [1/2/3] or type <RETURN> for the highlited default"
echo ""
echononl "Eingabe: "
;;
esac
done
if [[ ${_CHOOSE} -gt 2 ]] ; then
echo ""
clean_up 0
elif [[ ${_CHOOSE} -gt 1 ]] ; then
_MOUNT_DIR_BACKUP_HOST="${BORG_FUSE_MOUNT_DIR}/$(basename "${BORG_REPO}")/${BORG_BACKUP_ID}"
echo -e "\033[40m\033[37m
-----------------------------------------------------------------------------------------
export BORG_PASSPHRASE=\"${BORG_PASSPHRASE}\"
export BORG_REPO=\"${BORG_REPO}\"
export BORG_RSH=\"${BORG_RSH}\"
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
mkdir -p \"${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}\"
borg mount ${BORG_URL}::${BORG_BACKUP_ID} ${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID} ${LIST_OF_FILES_OR_DIRECTORIES}
On Backup Host type:
====================
export BORG_PASSPHRASE=\"${BORG_PASSPHRASE}\"
export BORG_REPO=\"${BORG_REPO}\"
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
mkdir -p \"${_MOUNT_DIR_BACKUP_HOST}\"
borg mount ${BORG_REPO}::${BORG_BACKUP_ID} ${_MOUNT_DIR_BACKUP_HOST} ${LIST_OF_FILES_OR_DIRECTORIES}
You can find the mounted fuse archive at;
${_MOUNT_DIR_BACKUP_HOST}
In Order to unmount repository archive type:
umount ${_MOUNT_DIR_BACKUP_HOST}
-----------------------------------------------------------------------------------------
\033[m\n"
clean_up 0
fi
echononl "Create Mount Directory '${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}'."
if [ ! -d "${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}" ]; then
mkdir -p "${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}" > ${log_file} 2>&1
if [[ $? -gt 0 ]] ; then
echo_failed
error "$(cat "${log_file}")"
fatal "Mount directory '${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}' present!"
else
echo_ok
fi
else
echo_skipped
fi
blank_line
_MOUNT_DIR_BACKUP_HOST="${BORG_FUSE_MOUNT_DIR}/$(basename "${BORG_REPO}")/${BORG_BACKUP_ID}"
echo -e "\033[40m\033[37m
-----------------------------------------------------------------------------------------
export BORG_PASSPHRASE=\"${BORG_PASSPHRASE}\"
export BORG_REPO=\"${BORG_REPO}\"
export BORG_RSH=\"${BORG_RSH}\"
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
mkdir -p \"${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}\"
borg mount ${BORG_URL}::${BORG_BACKUP_ID} ${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID} ${LIST_OF_FILES_OR_DIRECTORIES}
On Backup Host type:
====================
export BORG_PASSPHRASE=\"${BORG_PASSPHRASE}\"
export BORG_REPO=\"${BORG_REPO}\"
export BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
mkdir -p \"${_MOUNT_DIR_BACKUP_HOST}\"
borg mount ${BORG_REPO}::${BORG_BACKUP_ID} ${_MOUNT_DIR_BACKUP_HOST} ${LIST_OF_FILES_OR_DIRECTORIES}
You can find the mounted fuse archive at;
${_MOUNT_DIR_BACKUP_HOST}
In Order to unmount repository archive type:
umount ${_MOUNT_DIR_BACKUP_HOST}
-----------------------------------------------------------------------------------------
\033[m\n"
blank_line
echo " Mount archive '${BORG_REPO}::${BORG_BACKUP_ID}' to"
echononl " '${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID}'.."
borg mount ${BORG_URL}::${BORG_BACKUP_ID} ${BORG_FUSE_MOUNT_DIR}/${BORG_BACKUP_ID} ${LIST_OF_FILES_OR_DIRECTORIES} > "${log_file}" 2>&1
if [[ $? -gt 0 ]] ; then
echo_failed