del legacy b2, add rclone

This commit is contained in:
2022-12-14 13:39:39 +07:00
parent 8a9a1edc71
commit b649a6d7ba
11 changed files with 76 additions and 197 deletions
+1
View File
@@ -1,4 +1,5 @@
S3_BUCKET=amega
S3_HOST_BASE=s3.amegaserver.com
S3_REGION=ru-nsk
S3_ACCOUNT_ID=
S3_APPLICATION_KEY=
-39
View File
@@ -1,39 +0,0 @@
#!/usr/bin/env bash
storage_login() {
B2_REMOTE_DIR=${STORAGE_PATH#*/}
B2_BUCKET=${STORAGE_PATH%%/*}
B2_ARCHIVE=${B2_REMOTE_DIR}/$(basename ${ARCHIVE})
B2_ACCOUNT_ID=${ACCOUNT_ID}
B2_APPLICATION_KEY=${APPLICATION_KEY}
if [[ -n "${DEBUG}" ]]; then
echo B2_BUCKET=${B2_BUCKET}
echo B2_REMOTE_DIR=${B2_REMOTE_DIR}
echo B2_ARCHIVE=${B2_ARCHIVE}
echo ARCHIVE=${ARCHIVE}
fi
B2_CONNECTION=
b2 authorize-account ${B2_ACCOUNT_ID} ${B2_APPLICATION_KEY}
log "Login to B2 by ${B2_ACCOUNT_ID}" && export B2_CONNECTION=true
return $?
}
storage_download() {
[ -z ${B2_CONNECTION} ] && storage_login
b2 download-file-by-name ${B2_BUCKET} ${B2_ARCHIVE} ${ARCHIVE}
log "Download in \"${B2_ARCHIVE}\" from bucket \"${B2_BUCKET}\" \n\t as \"$(basename ${ARCHIVE})\""
return $?
}
storage_upload() {
[ -z ${B2_CONNECTION} ] && storage_login
b2 upload-file ${B2_BUCKET} ${ARCHIVE} ${B2_ARCHIVE}
log "Upload \"$(basename ${ARCHIVE})\" \n\t to \"${B2_ARCHIVE}\" in bucket \"${B2_BUCKET}\""
return $?
}
+9 -13
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
S3_HOST_BASE=${STORAGE_HOST:-s3.amazonaws.com}
S3_REGION=${S3_REGION:-us-west}
S3_REMOTE_DIR=${STORAGE_PATH#*/}
S3_BUCKET=${STORAGE_PATH%%/*}
@@ -14,39 +15,34 @@ S3_CONNECTION=
if [[ -n "${DEBUG}" ]]; then
echo S3_BUCKET=${S3_BUCKET}
echo S3_REGION=${S3_REGION}
echo S3_REMOTE_DIR=${S3_REMOTE_DIR}
echo S3_ARCHIVE=${S3_ARCHIVE}
fi
storage_login() {
[ -f /root/.s3cfg ] && rm /root/.s3cfg
config=/root/.config/rclone/rclone.config
[ -f $config ] && rm $config
echo S3_BUCKET=${S3_BUCKET} > .env
echo S3_REGION=${S3_REGION} >> .env
echo S3_HOST_BASE=${S3_HOST_BASE} >> .env
echo S3_ACCOUNT_ID=${ACCOUNT_ID} >> .env
echo S3_APPLICATION_KEY=${APPLICATION_KEY} >> .env
mo -s=.env -u /usr/local/sbin/storage/s3.template > /root/.s3cfg
mo -s=.env -u /usr/local/sbin/storage/s3.template > $config
log "Setup to S3 by ${S3_ACCOUNT_ID}" && \
log "Setup to S3 by ${S3_ACCOUNT_ID} to ${S3_HOST_BASE}" && \
export S3_CONNECTION=true
return $?
}
storage_download() {
[ -z ${S3_CONNECTION} ] && storage_login
s3cmd get s3://${S3_BUCKET}/${S3_ARCHIVE} ${ARCHIVE}
log "Download \"${S3_ARCHIVE}\" from bucket \"${S3_BUCKET}\" \n\t as \"${ARCHIVE}\""
return $?
}
storage_upload() {
[ -z ${S3_CONNECTION} ] && storage_login
log "Upload \"${ARCHIVE}\" \n\t as \"${S3_ARCHIVE}\" in \"${S3_BUCKET}\""
s3cmd put --multipart-chunk-size-mb=${CHUNK_SIZE:-15} ${ARCHIVE} s3://${S3_BUCKET}/${S3_ARCHIVE}
rclone copy --progress --transfers=5 --update --s3-chunk-size=${CHUNK_SIZE:-100m} ${ARCHIVE} s3:/${S3_BUCKET}/${S3_ARCHIVE}
return $?
}
+8 -81
View File
@@ -1,81 +1,8 @@
[default]
access_key = {{S3_ACCOUNT_ID}}
access_token =
add_encoding_exts =
add_headers =
bucket_location = US
ca_certs_file =
cache_file =
check_ssl_certificate = True
check_ssl_hostname = True
cloudfront_host = cloudfront.amazonaws.com
content_disposition =
content_type =
default_mime_type = binary/octet-stream
delay_updates = False
delete_after = False
delete_after_fetch = False
delete_removed = False
dry_run = False
enable_multipart = True
encoding = UTF-8
encrypt = False
expiry_date =
expiry_days =
expiry_prefix =
follow_symlinks = False
force = False
get_continue = False
gpg_command = /usr/local/bin/gpg
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_passphrase =
guess_mime_type = True
host_base = {{S3_HOST_BASE}}
host_bucket = {{S3_BUCKET}}.{{S3_HOST_BASE}}
human_readable_sizes = False
invalidate_default_index_on_cf = False
invalidate_default_index_root_on_cf = True
invalidate_on_cf = False
kms_key =
limit = -1
limitrate = 0
list_md5 = False
log_target_prefix =
long_listing = False
max_delete = -1
mime_type =
multipart_chunk_size_mb = 15
multipart_max_chunks = 10000
preserve_attrs = True
progress_meter = True
proxy_host =
proxy_port = 0
put_continue = False
recursive = False
recv_chunk = 65536
reduced_redundancy = False
requester_pays = False
restore_days = 1
restore_priority = Standard
secret_key = {{S3_APPLICATION_KEY}}
send_chunk = 65536
server_side_encryption = False
signature_v2 = False
signurl_use_https = False
simpledb_host = sdb.amazonaws.com
skip_existing = False
socket_timeout = 300
stats = False
stop_on_error = False
storage_class =
throttle_max = 100
upload_id =
urlencoding_mode = normal
use_http_expect = False
use_https = True
use_mime_magic = True
verbosity = WARNING
website_endpoint = http://%(bucket)s.s3-website-%(location)s.amazonaws.com/
website_error =
website_index = index.html
[s3]
type = s3
provider = Minio
acl = private
access_key_id = {{S3_ACCOUNT_ID}}
secret_access_key = {{S3_APPLICATION_KEY}}
region = {{S3_REGION}}
endpoint = https://{{S3_HOST_BASE}}