make .s3cfg default
This commit is contained in:
parent
340d353b78
commit
9f1a7312d5
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# s3cmd.sh - upload files to S3 compatible object storage.
|
# s3cmd.sh - upload files to S3 compatible object storage via s3cmd.
|
||||||
# Copyright (c) 2022 ge <https://nixhacks.net/>
|
# Copyright (c) 2022 ge <https://nixhacks.net/>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@ -41,17 +41,12 @@ tgt_s3cmd() {
|
|||||||
s3cmd_options="${s3cmd_options:---preserve --quiet --no-progress}"
|
s3cmd_options="${s3cmd_options:---preserve --quiet --no-progress}"
|
||||||
|
|
||||||
# Set s3cmd comand. See s3cmd(1)
|
# Set s3cmd comand. See s3cmd(1)
|
||||||
if [ -n "$s3cmd_config" ]; then
|
if [ -n "$s3_access_key" ] && \
|
||||||
# Use configuration file
|
|
||||||
# shellcheck disable=SC2154,SC2086
|
|
||||||
set -- s3cmd $s3cmd_options --config "$s3cmd_config" \
|
|
||||||
put "${backups[@]}" "$uri"
|
|
||||||
elif [ -n "$s3_access_key" ] && \
|
|
||||||
[ -n "$s3_secret_key" ] && \
|
[ -n "$s3_secret_key" ] && \
|
||||||
[ -n "$s3_host" ] && \
|
[ -n "$s3_host" ] && \
|
||||||
[ -n "$s3_host_bucket" ]
|
[ -n "$s3_host_bucket" ]
|
||||||
then
|
then
|
||||||
s3_region="${s3_region:-na}" # fallback to 'no available' region
|
s3_region="${s3_region:-na}" # fallback to 'not available' region
|
||||||
# Use parameters provided from backup script
|
# Use parameters provided from backup script
|
||||||
# shellcheck disable=SC2154,SC2086
|
# shellcheck disable=SC2154,SC2086
|
||||||
set -- s3cmd $s3cmd_options \
|
set -- s3cmd $s3cmd_options \
|
||||||
@ -62,10 +57,11 @@ tgt_s3cmd() {
|
|||||||
--host-bucket="$s3_host_bucket" \
|
--host-bucket="$s3_host_bucket" \
|
||||||
put "${backups[@]}" "$uri"
|
put "${backups[@]}" "$uri"
|
||||||
else
|
else
|
||||||
# Exit if no configuration
|
# Use configuration file
|
||||||
log -p "Error: Bad s3cmd credentials."\
|
s3cmd_config="${s3cmd_comfig:-$HOME/.s3cfg}"
|
||||||
"See boring-backup(1) for details" >&2
|
# shellcheck disable=SC2154,SC2086
|
||||||
exit 1
|
set -- s3cmd $s3cmd_options --config "$s3cmd_config" \
|
||||||
|
put "${backups[@]}" "$uri"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Run command: $*" |
|
echo "Run command: $*" |
|
||||||
@ -74,7 +70,7 @@ tgt_s3cmd() {
|
|||||||
|
|
||||||
# Upload backups
|
# Upload backups
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if "$@" 2>> "$__log_file"; then
|
if "$@" 2>> "$log_file"; then
|
||||||
: # Success
|
: # Success
|
||||||
else
|
else
|
||||||
handle_error \
|
handle_error \
|
||||||
|
Loading…
Reference in New Issue
Block a user