feat: Add variable name_suffix; Pass shellcheck; Discard useless variables from main script

This commit is contained in:
ge
2022-06-29 21:27:35 +03:00
parent 3d514678e7
commit aaa7a5c2d3
11 changed files with 177 additions and 147 deletions

View File

@ -32,12 +32,14 @@ handler::mysqldump() {
local file_ext
uri="$1"
# shellcheck disable=SC2154
dst_path="$__main_target_path"
parse_uri "$uri"
[ -z "$port" ] && port=3306 # Set default MySQL port.
# shellcheck disable=SC2154
[ -n "$__verbose" ] && echo "Dumping database '${path##*/}'"\
"owned by ${username}@${hostname} ..." | log -p
@ -61,7 +63,10 @@ handler::mysqldump() {
compr_cmd="cat"
fi
mysqldump_opts="${mysqldump_opts:-}"
# NOTE! mysqldump_opts and compr_cmd variables must be unquoted!
# shellcheck disable=SC2086,SC2154
try mysqldump $mysqldump_opts \
--host="$hostname" \
--port="$port" \
@ -76,33 +81,32 @@ handler::mysqldump() {
fi
}
# POSTGRESQL vvv
bk_dump_postgresql() {
# Do PostgreSQL dump.
bk_log "Dumping database '${path##*/}' owned by ${user}@${host} (PostgreSQL) ..."
dump_name="$entry_local"/"$(bk_get_name "$db_name" .psql.gz)"
[ "$port" ] || port=5432 # Set default PostgreSQL port.
export PGPASSWORD="$password"
pg_dump \
--host="$host" \
--port="$port" \
--dbname="${path##*/}" \
--username="$user" \
--no-password | gzip -c > "$dump_name" |& bk_log
unset PGPASSWORD
if [ -s "$dump_name" ]; then
bk_log "Dumping database '${path##*/}' owned by ${user}@${host} (PostgreSQL) [Done]"
bk_log "Dump saved as: $dump_name"
bk_upload_file "$dump_name"
else
rm "$dump_name"
bk_err "Something went wrong. Dump size is 0 bytes. Removing $dump_name"
fi
}
# POSTGRESQL
#bk_dump_postgresql() {
# # Do PostgreSQL dump.
#
# bk_log "Dumping database '${path##*/}' owned by ${user}@${host} (PostgreSQL) ..."
#
# dump_name="$entry_local"/"$(bk_get_name "$db_name" .psql.gz)"
# [ "$port" ] || port=5432 # Set default PostgreSQL port.
# export PGPASSWORD="$password"
#
# pg_dump \
# --host="$host" \
# --port="$port" \
# --dbname="${path##*/}" \
# --username="$user" \
# --no-password | gzip -c > "$dump_name" |& bk_log
#
# unset PGPASSWORD
#
# if [ -s "$dump_name" ]; then
# bk_log "Dumping database '${path##*/}' owned by ${user}@${host} (PostgreSQL) [Done]"
# bk_log "Dump saved as: $dump_name"
# bk_upload_file "$dump_name"
#
# else
# rm "$dump_name"
# bk_err "Something went wrong. Dump size is 0 bytes. Removing $dump_name"
# fi
#}