add building process and contianer
continuous-integration/drone/tag Build is failing

This commit is contained in:
victor.kolomin committed 2025-10-01 21:58:08 +02:00
1 parent f33d13ed2a
commit bfe4579c4c
3 files changed
+109

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
kind: pipeline
type: docker
name: build-control-container
steps:
- name: build and push
image: plugins/docker
settings:
repo: https://git.kolspace.cc/victor.kolomin/docker-rustic-backup
registry: git.kolspace.cc
tags:
- ${DRONE_TAG}
dockerfile: Dockerfile
context: .
platforms: linux/amd64
username:
from_secret: registry_user
password:
from_secret: registry_pass
trigger:
event:
- tag
+24
View File
@@ -0,0 +1,24 @@
# Dockerfile
FROM alpine:latest
# Install dependencies: bash, curl, and the cron daemon (dcron)
RUN apk update && \
apk add --no-cache bash curl dcron
# --- Install Rustic ---
# Define the version of Rustic to install
ENV RUSTIC_VERSION=v0.10.0
# IMPORTANT: Check the latest version on the Rustic GitHub release page!
RUN curl -L "https://github.com/rustic-rs/rustic/releases/download/v${RUSTIC_VERSION}/rustic-v${RUSTIC_VERSION}-x86_64-unknown-linux-musl.tar.gz" | tar -xz -C /usr/local/bin/
# --- Setup Scripts ---
# Copy the core backup executor script (will be called by cron)
COPY backup.sh /usr/local/bin/backup.sh
RUN chmod +x /usr/local/bin/backup.sh
# Copy the daemon startup script (launches cron and keeps container alive)
COPY start.sh /start.sh
RUN chmod +x /start.sh
# Set the entry point to the daemon startup script
CMD ["/start.sh"]
+62
View File
@@ -0,0 +1,62 @@
#!/bin/bash
# backup.sh: The pure executor script called by cron.
# Exit immediately if a command exits with a non-zero status.
set -e
# ----------------------------------------------------
# 1. VALIDATION (Ensure Executor Variables Are Set)
# ----------------------------------------------------
# Validate required variables (though RUSTIC_REPOSITORY/PASSWORD are implicitly checked by Rustic)
if [ -z "$BACKUP_PATHS" ]; then
echo "ERROR: BACKUP_PATHS environment variable is not set. Exiting executor."
exit 1
fi
# PRUNE_POLICY is optional, default if not set
PRUNE_POLICY=${PRUNE_POLICY:-"--keep-daily 7 --keep-weekly 4 --keep-monthly 12"}
# ----------------------------------------------------
# 2. INITIALIZATION (Check and Initialize Repository)
# ----------------------------------------------------
echo "$(date): --> Checking repository availability..."
# Check for repository errors. If an error is found, initialize it.
if rustic check --json 2>&1 | grep -q 'error'; then
echo "$(date): Repository not found or seems damaged. Attempting to initialize..."
rustic init
fi
# ----------------------------------------------------
# 3. RUN THE BACKUP (Backup)
# ----------------------------------------------------
echo "$(date): --> Starting backup process for paths: ${BACKUP_PATHS}"
rustic backup ${BACKUP_PATHS}
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "$(date): !!! BACKUP FAILED (exit code $STATUS) !!!"
# Optional: Add external notification logic here
exit 1
fi
echo "$(date): Backup successfully completed."
# ----------------------------------------------------
# 4. CLEANUP OLD SNAPSHOTS (Prune/Forget)
# ----------------------------------------------------
echo "$(date): --> Starting cleanup (prune/forget) with policy: ${PRUNE_POLICY}"
rustic prune --forget ${PRUNE_POLICY}
# ----------------------------------------------------
# 5. VERIFY INTEGRITY (Check)
# ----------------------------------------------------
# Note: Check is kept for completeness, but can be disabled or scheduled separately
# to reduce daily resource usage.
echo "$(date): --> Running integrity check (check)..."
rustic check
echo "$(date): --- ALL BACKUP TASKS COMPLETED SUCCESSFULLY. ---"