Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backups section to mongodbent docs. #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dynamic-storage.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## <a id='endpoints'></a> ECS endpoints / access points

| Trust Level | URL | Usecase
Expand Down
3 changes: 3 additions & 0 deletions mongodbent.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## <a id='backups'></a> 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backman app should be linked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also restored on-demand.
Should be written as 'and restored on-demand.'

49 changes: 49 additions & 0 deletions scripts/s3cleanup.sh
Original file line number Diff line number Diff line change
@@ -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"