feat: Rename handler functions, remove gen_backup_name
This commit is contained in:
parent
0e2f95337d
commit
f6dbb64fe8
@ -30,21 +30,22 @@ process_source() {
|
||||
# Process Path-only URI
|
||||
if [[ "$scheme" == "$uri" ]]; then scheme='file'; fi
|
||||
|
||||
echo -e "Processing source $uri ..."
|
||||
echo -e "Processing source $uri ..." |
|
||||
sed 's/:\/\//\[auth\]/;s/:.*@/:xxx@/;s/\[auth\]/:\/\//'
|
||||
# ^^^ hide password from output ^^^
|
||||
|
||||
case "$scheme" in
|
||||
file) handler='handler::tar';;
|
||||
mysql) handler='handler::mysqldump';;
|
||||
postgres) handler='handler::pg_dump';;
|
||||
sqlite) handler='handler::sqlite';;
|
||||
file) handler='src_tar';;
|
||||
mysql|mariadb) handler='src_mysqldump';;
|
||||
postgres) handler='src_pg_dump';;
|
||||
sqlite) handler='src_sqlite';;
|
||||
*) # shellcheck disable=SC2154
|
||||
# '__user_script' is assigned in main script.
|
||||
echo "Error: $__user_script: Unsupported URI scheme: $scheme" >&2
|
||||
# 'backup_script' is assigned in main script.
|
||||
echo "Error: $backup_script: Unsupported URI scheme: $scheme" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
# Run handler function
|
||||
[ "$__verbose" ] && echo "Run handler ${handler}()"
|
||||
"$handler" "$uri"
|
||||
}
|
||||
|
||||
@ -65,20 +66,19 @@ process_target() {
|
||||
echo -e "Processing target $uri ..."
|
||||
|
||||
case "$scheme" in
|
||||
file) handler='handler::cp';;
|
||||
ftp) handler='handler::ftp';;
|
||||
sftp) handler='handler::sftp';;
|
||||
rsync) handler='handler::rsync';;
|
||||
s3) handler='handler::s3';;
|
||||
sj) handler='handler::sj';;
|
||||
swift) handler='handler::swift';;
|
||||
dav) handler='handler::dav';;
|
||||
davs) handler='handler::davs';;
|
||||
file) handler='tgt_cp';;
|
||||
ftp) handler='tgt_ftp';;
|
||||
sftp) handler='tgt_sftp';;
|
||||
rsync) handler='tgt_rsync';;
|
||||
s3) handler='tgt_s3';;
|
||||
sj) handler='tgt_sj';;
|
||||
swift) handler='tgt_swift';;
|
||||
dav) handler='tgt_dav';;
|
||||
davs) handler='tgt_davs';;
|
||||
*) echo "Error: Unsupported URI scheme: $scheme" >&2; exit 1;;
|
||||
esac
|
||||
|
||||
# Run handler function
|
||||
[ "$__verbose" ] && echo "Run handler ${handler}()"
|
||||
"$handler" "$uri"
|
||||
}
|
||||
|
||||
@ -97,25 +97,3 @@ builtin_backup() {
|
||||
process_target "$target"
|
||||
done
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------- #
|
||||
# * Helper functions #
|
||||
# ---------------------------------------------------------- #
|
||||
|
||||
gen_backup_name() {
|
||||
# Generate backup file name. Write resulting string to STDOUT.
|
||||
#
|
||||
# Usage: gen_backup_name NAME_EXT
|
||||
|
||||
local name
|
||||
local name_ext
|
||||
|
||||
name_prefix="${name_prefix:-${__user_script}_}"
|
||||
# shellcheck disable=SC2154
|
||||
name="$(basename "$path")" # 'path' is variable parsed from URI
|
||||
name_ext="$1"
|
||||
name_date_fmt="${name_date_fmt:-_%Y.%m.%d}"
|
||||
name_suffix="${name_suffix:--%H%M}"
|
||||
|
||||
date +"${name_prefix}${name}${name_date_fmt}${name_suffix}${name_ext}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user