Skip to content

Commit eaa4444

Browse files
authored
Update backup.sh
1 parent 3d36f38 commit eaa4444

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

backups/backup.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ set -o pipefail -ue
77
LOCKFILE=/opt/parmincloud/backups/backup.lock
88
exec 100>"$LOCKFILE"
99

10+
AWS="$(which aws)"
11+
1012
remove-lock() {
1113
flock -u 100
1214
flock -xn 100
@@ -46,16 +48,16 @@ if [ -n "$S3_PREFIX" ]; then
4648
S3_UPLOAD_URI="s3://${S3_BUCKET}/${S3_PREFIX}/$REMOTE_FILENAME"
4749
fi
4850

49-
aws s3 cp "$LOCAL_FILENAME" "$S3_UPLOAD_URI"
51+
$AWS s3 cp "$LOCAL_FILENAME" "$S3_UPLOAD_URI"
5052

5153
if [ -n "$BACKUP_RETENTION_DAYS" ]; then
5254
log "Removing old backups from S3..."
5355
S3_RETENTION_QUERY="Contents[?LastModified<='$(subtract-date-from-now $BACKUP_RETENTION_DAYS) 00:00:00'].{Key: Key}"
54-
aws s3api list-objects \
56+
$AWS s3api list-objects \
5557
--bucket "${S3_BUCKET}" \
5658
--prefix "${S3_PREFIX:-}" \
5759
--query "${S3_RETENTION_QUERY}" \
58-
--output text | xargs -P "$(nproc)" -I '{}' aws s3 rm "s3://${S3_BUCKET}/{}"
60+
--output text | xargs -P "$(nproc)" -I '{}' $AWS s3 rm "s3://${S3_BUCKET}/{}"
5961
fi
6062

6163
log "Backup successfully done"

0 commit comments

Comments
 (0)