mirror of
https://github.com/ben-grande/qusal.git
synced 2024-10-01 02:35:49 -04:00
fix: remove colors from output of backup file
This commit is contained in:
parent
a59a35860c
commit
fc2af9b619
@ -1,17 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
||||
# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
set -eu
|
||||
|
||||
list_backups(){
|
||||
## Hide stderr to hide remote login connection messages (banners etc).
|
||||
# shellcheck disable=SC2086
|
||||
${qrun_cmd} "${qube}" -- "${cmd} ${find_cmd} 2>/dev/null"
|
||||
}
|
||||
|
||||
list_last_backup(){
|
||||
list_backups | tail -1
|
||||
}
|
||||
|
||||
usage(){
|
||||
printf '%s\n' "usage: ${0##*/} QUBE DIR [CMD]"
|
||||
printf '%s\n' "example: ${0##*/} usb-qube /local/dir/backups"
|
||||
printf '%s\n' "example: ${0##*/} ssh-qube /remote/dir/backups 'ssh user@server'"
|
||||
printf '%s\n' "note: when using a remote login command (ssh), the DIR is the remote directory"
|
||||
printf '%s\n' "note: the directory specified must be the parent of where the backups are saved"
|
||||
printf '%s\n' "Usage: ${0##*/} QUBE DIR [CMD]
|
||||
example: ${0##*/} usb-qube /local/dir/backups
|
||||
example: ${0##*/} ssh-qube /remote/dir/backups 'ssh user@server'
|
||||
note: when using a remote login command (ssh), DIR is the remote directory
|
||||
note: the directory specified must be the parent of the saved backups"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -19,9 +29,17 @@ if test -z "${2-}"; then
|
||||
usage
|
||||
fi
|
||||
|
||||
qube="$1"
|
||||
path="$2"
|
||||
qube="${1}"
|
||||
path="${2}"
|
||||
cmd="${3-}"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
qvm-run -p "$qube" $cmd find "$path" -maxdepth 1 -type f -name "qubes-backup-*" 2>/dev/null | tail -1
|
||||
find_pattern="qubes-backup-*"
|
||||
find_cmd="find \"${path}\" -maxdepth 1 -type f -name \"${find_pattern}\""
|
||||
qrun_cmd="qvm-run --filter-escape-chars --no-color-output --no-color-stderr --pass-io"
|
||||
|
||||
last_backup="$(list_last_backup)"
|
||||
if test -z "${last_backup}"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "${last_backup}"
|
||||
|
Loading…
Reference in New Issue
Block a user