Skip to content

Commit 028966d

Browse files
authored
Merge pull request #171 from greena13/bugfix/s3_backup_cleanup
Bugfix: S3 database cleanups
2 parents 19d8e98 + 25def5b commit 028966d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ Your Organization will be mapped to `DB_USER` and your root token will need to b
192192
If `BACKUP_LOCATION` = `S3` then the following options are used.
193193

194194
| Parameter | Description | Default |
195-
| --------------------- | ----------------------------------------------------------------------------------------- | ------- |
195+
|-----------------------|-------------------------------------------------------------------------------------------|---------|
196196
| `S3_BUCKET` | S3 Bucket name e.g. `mybucket` | |
197197
| `S3_KEY_ID` | S3 Key ID | |
198198
| `S3_KEY_SECRET` | S3 Key Secret | |
199-
| `S3_PATH` | S3 Pathname to save to e.g. '`backup`' | |
199+
| `S3_PATH` | S3 Pathname to save to (must end in a trailing slash e.g. '`backup/`') | |
200200
| `S3_REGION` | Define region in which bucket is defined. Example: `ap-northeast-2` | |
201201
| `S3_HOST` | Hostname (and port) of S3-compatible service, e.g. `minio:8080`. Defaults to AWS. | |
202202
| `S3_PROTOCOL` | Protocol to connect to `S3_HOST`. Either `http` or `https`. Defaults to `https`. | `https` |

install/assets/functions/10-db-backup

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,15 @@ cleanup_old_data() {
464464
;;
465465
"s3" | "minio" )
466466
print_info "Cleaning up old backups"
467-
aws ${PARAM_AWS_ENDPOINT_URL} s3 ls s3://${S3_BUCKET}/${S3_PATH} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS} | grep " DIR " -v | while read -r s3_file; do
467+
aws ${PARAM_AWS_ENDPOINT_URL} s3 ls s3://${S3_BUCKET}/${S3_PATH} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS} | grep " DIR " -v | grep " PRE " -v | while read -r s3_file; do
468468
s3_createdate=$(echo $s3_file | awk {'print $1" "$2'})
469469
s3_createdate=$(date -d "$s3_createdate" "+%s")
470470
s3_olderthan=$(echo $(( $(date +%s)-${DB_CLEANUP_TIME}*60 )))
471471
if [[ $s3_createdate -le $s3_olderthan ]] ; then
472472
s3_filename=$(echo $s3_file | awk {'print $4'})
473473
if [ "$s3_filename" != "" ] ; then
474474
print_debug "Deleting $s3_filename"
475-
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 rm s3://${S3_BUCKET}/${S3_PATH}/${s3_filename} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
475+
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 rm s3://${S3_BUCKET}/${S3_PATH}${s3_filename} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
476476
fi
477477
fi
478478

@@ -815,4 +815,3 @@ EOF
815815
fi
816816
fi
817817
}
818-

0 commit comments

Comments
 (0)