Skip to content

Commit

Permalink
Merge pull request #50 from lsst-sqre/tickets/DM-46938
Browse files Browse the repository at this point in the history
Build docker image with backup tools
  • Loading branch information
afausti authored Dec 13, 2024
2 parents e0a1656 + dfd2ed2 commit 55c8447
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

"on":
merge_group: {}
pull_request: {}
push:
tags:
- "*"

jobs:

build:
runs-on: ubuntu-latest

# Only do Docker builds of tagged releases and pull requests from ticket
# branches.
if: >
startsWith(github.ref, 'refs/tags/')
|| startsWith(github.head_ref, 'tickets/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: lsst-sqre/build-and-push-to-ghcr@v1
id: build
with:
image: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- run: echo Pushed ghcr.io/${{ github.repository }}:${{ steps.build.outputs.tag }}
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Start from the InfluxDB Enterprise Meta image
# This provides the InfluxDB Enterprise influxd-ctl command
FROM influxdb:1.11.8-meta

# Install pipx and use it to install gsutil which is required for the backup script
# to upload the backup files to Google Cloud Storage
RUN apt-get update && \
apt-get install -y python3 python3-pip pipx && \
pipx install gsutil && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Add pipx bin directory to PATH
ENV PATH="/root/.local/bin:$PATH"

# Verify gsutil installation
RUN gsutil --version

# Add the backup script
COPY backup/backup.sh /usr/local/bin/backup.sh
RUN chmod +x /usr/local/bin/backup.sh

# Create a new user to run the backup script
RUN useradd --create-home sasquatch

# Switch to the non-root user.
USER sasquatch

# Set the default command for the container
CMD ["/usr/local/bin/backup.sh"]
23 changes: 23 additions & 0 deletions backup/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

# Configuration
BACKUP_DIR="/backup/sasquatch-influxdb-enterprise-backup"
GCS_BUCKET="gs://your-gcs-bucket"

# Ensure the backup directory exists
mkdir -p "$BACKUP_DIR"

echo "Starting InfluxDB Enterprise backup..."

influxd-ctl -bind sasquatch-influxdb-enterprise-meta.sasquatch:8091 backup -strategy incremental "$BACKUP_DIR"

if [ $? -eq 0 ]; then
echo "Backup completed successfully at $BACKUP_DIR."
else
echo "Backup failed!" >&2
exit 1
fi


0 comments on commit 55c8447

Please sign in to comment.