From 75317f1bdcbdbb2c3ac0f85615065fb9c5ff2987 Mon Sep 17 00:00:00 2001 From: Toni Stjepanovic Date: Wed, 9 Oct 2019 14:08:28 +0200 Subject: [PATCH 1/3] Add backman hint to mongodbent docs as there wasn't any info regarding backups on that page. --- mongodbent.html.md.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mongodbent.html.md.erb b/mongodbent.html.md.erb index 869180d..867aac6 100644 --- a/mongodbent.html.md.erb +++ b/mongodbent.html.md.erb @@ -116,3 +116,6 @@ On the MongoDB Ops Manager you will receive the role `Monitoring Admin`. - Consider a query timeout MongoDB targets operations for termination if the associated cursor exceeds its allotted time limit. See [cursor.maxTimeMS()](https://docs.mongodb.com/manual/reference/method/cursor.maxTimeMS/) for more details. + +## Backups +You can use following app to create and restore backups in a scheduled way: backman - the appcloud backup manager. Any MongoDB service instance bound to this app will be automatically backed up, can be downloaded and also restored on-demand. From 213a55fc0b72938e18a19cd4da98b37d4be45f7c Mon Sep 17 00:00:00 2001 From: Toni Stjepanovic Date: Wed, 20 Jan 2021 15:35:42 +0100 Subject: [PATCH 2/3] Add script to clean up s3 instance buckets/files. --- scripts/s3cleanup.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 scripts/s3cleanup.sh diff --git a/scripts/s3cleanup.sh b/scripts/s3cleanup.sh new file mode 100755 index 0000000..be677c1 --- /dev/null +++ b/scripts/s3cleanup.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -eu + +# check input params, s3cmd config, installed dependencies +if [ -z "$*" ]; then echo "Usage: s3cleanup.sh ORG SPACE SERVICE_NAME"; exit 1; fi +if [ -f $HOME/.s3cfg ]; then echo "s3cmd config $HOME/.s3cfg already exists, please rename temporarily. Aborting."; exit 1; fi +command -v cf >/dev/null 2>&1 || { echo >&2 "cf cli not installed. Aborting."; exit 1; } +command -v s3cmd >/dev/null 2>&1 || { echo >&2 "s3cmd not installed. Aborting."; exit 1; } +command -v jq >/dev/null 2>&1 || { echo >&2 "jq not installed. Aborting."; exit 1; } + +#read input params +org=$1 +space=$2 +service=$3 + +#change to org/space and create temporary service key +cf t -o $org -s $space +cf csk $service tempkey + +#parse s3cmd config from service key +service_key=`cf service-key $service tempkey|tail -n 8` +access_key=`echo $service_key|jq -r .accessKey` +host_base=`echo $service_key|jq -r .namespaceHost|cut -d "." -f 2-4` +host_bucket=`echo $service_key|jq -r .namespaceHost` +secret_key=`echo $service_key|jq -r .sharedSecret` + +#heredoc to create s3cmd config in the users homedir +echo "Creating $HOME/.s3cfg" && cat << EOF > $HOME/.s3cfg +[default] +access_key = $access_key +host_base = $host_base +host_bucket = $host_bucket +secret_key = $secret_key +EOF + +#delete all buckets +echo "Trying to delete all files/buckets on $service." +s3cmd ls|awk '{print $3}' | while read bucket; do #loop through buckets + s3cmd del --recursive $bucket --force #delete bucket content + s3cmd rb $bucket #remove actual bucket +done +rm $HOME/.s3cfg +echo "Finished deleting files/buckets on $service." + +echo "Removing temporary service key." +cf delete-service-key $service tempkey -f + +echo "You can now try to delete your s3 instance. This will only work if no remaining service keys/service shares exist." +echo "Command: cf delete-service $service" From e28e5279643af0f5d0ac723e8772b9a67af40a37 Mon Sep 17 00:00:00 2001 From: Toni Stjepanovic Date: Wed, 20 Jan 2021 15:52:08 +0100 Subject: [PATCH 3/3] Add documentation of s3 cleanup helper script to public docs. --- dynamic-storage.html.md.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dynamic-storage.html.md.erb b/dynamic-storage.html.md.erb index ab5fc34..28e1ea8 100644 --- a/dynamic-storage.html.md.erb +++ b/dynamic-storage.html.md.erb @@ -55,9 +55,10 @@ To do so, you can use the [S3cmd tool](http://s3tools.org/s3cmd) and run the fol ```shell $ s3cmd del --recursive s3://bucket-name ``` - In case you don't have any credentials for your Dynamic Storage instance, you can get them by creating a [service key](../devguide/services/service-keys.html). +Feel free to use our [bash helper script](https://github.com/swisscom/docs-appcloud-service-offerings/blob/master/scripts/s3cleanup.sh) to remove large numbers of s3 instances/buckets/files. + ## ECS endpoints / access points | Trust Level | URL | Usecase