-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add AWS S3 sync and management UI config backup #673
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
Changes from all commits
86f9d3c
79a6487
ce386a8
c8e20c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,6 +100,35 @@ if [ -f "$TEMPLATE" ]; then | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Keep objectstore-backed config in sync for management UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OBJECTSTORE_CONFIG_DIR="$CONFIG_DIR/objectstore/config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OBJECTSTORE_CONFIG="$OBJECTSTORE_CONFIG_DIR/config.yaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BACKUP_CONFIG_DIR="$CONFIG_DIR/backup/config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BACKUP_CONFIG="$BACKUP_CONFIG_DIR/config.yaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$OBJECTSTORE_CONFIG_DIR" "$BACKUP_CONFIG_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -f "$OBJECTSTORE_CONFIG" "$BACKUP_CONFIG" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp "$CONFIG" "$OBJECTSTORE_CONFIG" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp "$CONFIG" "$BACKUP_CONFIG" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Push config to objectstore so remote-backed config doesn't revert locally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "$OBJECTSTORE_ENDPOINT" ] && [ -n "$OBJECTSTORE_ACCESS_KEY" ] && [ -n "$OBJECTSTORE_SECRET_KEY" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @aws@ s3 sync \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --endpoint-url="$OBJECTSTORE_ENDPOINT" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$OBJECTSTORE_CONFIG_DIR/" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "s3://${OBJECTSTORE_BUCKET}/config/" || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="$OBJECTSTORE_SECRET_KEY" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @aws@ s3 sync \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --endpoint-url="$OBJECTSTORE_ENDPOINT" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$BACKUP_CONFIG_DIR/" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "s3://${OBJECTSTORE_BUCKET}/backup/config/" || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+114
to
+130
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two I recommend refactoring this logic into a function. This would not only reduce code duplication but also allow for proper error handling, such as logging a warning message on failure. This would make the script more robust and easier to maintain.
Suggested change
Comment on lines
+103
to
+130
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "$CONFIG_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Linux: Docker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
rm -fcommand is redundant because thecpcommands on the following lines will overwrite the destination files if they exist. You can safely remove this line to make the script slightly cleaner.