Skip to content

Commit

Permalink
Merge pull request #55 from lsst-sqre/tickets/DM-48357
Browse files Browse the repository at this point in the history
Add task to backup InfluxDB OSS
  • Loading branch information
afausti authored Jan 8, 2025
2 parents f505359 + bfd4104 commit 91ebc0e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<!-- Format for headings: 1.2.3 (YYYY-MM-DD) -->

## 1.2.0 (2025-01-08)

- Add full backups for InfluxDB OSS

## 1.1.0 (2025-01-06)

- Add Chronograf and Kapacitor backups
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/s
chmod +x kubectl && \
mv kubectl /usr/local/bin/

# Install influxd from InfluxDB OSS 1.11.8
RUN mkdir influxdb-1.11.8 && \
curl -LO "https://download.influxdata.com/influxdb/releases/influxdb-1.11.8-linux-amd64.tar.gz" && \
tar xf influxdb-1.11.8-linux-amd64.tar.gz -C influxdb-1.11.8 && \
mv influxdb-1.11.8/influxd /usr/local/bin/ && \
rm -rf influxdb-1.11.8-linux-amd64.tar.gz

# Verify influxd installation
RUN influxd version

# Add the backup script
COPY backup/backup.sh /usr/local/bin/backup.sh
RUN chmod +x /usr/local/bin/backup.sh
Expand Down
19 changes: 19 additions & 0 deletions backup/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ backup_influxdb_enterprise_incremental() {
fi
}

backup_influxdb_oss() {
echo "Backing up InfluxDB OSS (full backup)..."
backup_dir="/backup/sasquatch-influxdb-oss-$(date +%Y-%m-%d)"
backup_logs="/backup/sasquatch-influxdb-oss-$(date +%Y-%m-%d)/backup.logs"
mkdir -p "$backup_dir"
influxd backup -portable -host sasquatch-influxdb.sasquatch:8088 "$backup_dir" > $backup_logs 2>&1
if [ $? -eq 0 ]; then
echo "Backup completed successfully at $backup_dir."
echo "Cleaning up backups older than $retention_days day(s)..."
find /backup -type d -name "sasquatch-influxdb-oss-*" -mtime +$retention_days -exec rm -rf {} \;
else
echo "Backup failed!" >&2
exit 1
fi
}

if [ -z "$BACKUP_ITEMS" ]; then
echo "No backup items specified. Exiting."
exit 0
Expand All @@ -71,6 +87,9 @@ for item in $BACKUP_ITEMS; do
"influxdb-enterprise-incremental")
backup_influxdb_enterprise_incremental
;;
"influxdb-oss")
backup_influxdb_oss
;;
*)
echo "Unknown backup item: $name. Skipping..."
;;
Expand Down

0 comments on commit 91ebc0e

Please sign in to comment.