2 Commits

Author SHA1 Message Date
96e5e7500b change directory into source path before creating restic backup
All checks were successful
Build and Release Docker Image / Build and Push amd64 (push) Successful in 15s
Build and Release Docker Image / Build and Push arm64 (push) Successful in 27s
Build and Release Docker Image / Create and Push Multi-Arch Manifest (push) Successful in 18s
2025-02-05 19:33:43 +01:00
94f7c56932 improve cronjob example with best practices 2025-02-05 19:18:23 +01:00
2 changed files with 11 additions and 3 deletions

View File

@@ -50,16 +50,23 @@ Ensure the following commands are available in the container:
Example Kubernetes CronJob manifest for running BackupSidecar as a cron job for directory backups in minimal configuration: Example Kubernetes CronJob manifest for running BackupSidecar as a cron job for directory backups in minimal configuration:
```yaml ```yaml
apiVersion: batch/v1beta1 apiVersion: batch/v1
kind: CronJob kind: CronJob
metadata: metadata:
name: backupsidecar-cron name: backupsidecar-cron
namespace: authentik
spec: spec:
schedule: "0 2 * * *" # Run daily at 2:00 AM schedule: "0 7 * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 3
jobTemplate: jobTemplate:
spec: spec:
backoffLimit: 3
activeDeadlineSeconds: 300
template: template:
spec: spec:
restartPolicy: OnFailure
containers: containers:
- name: backupsidecar - name: backupsidecar
image: backupsidecar:latest image: backupsidecar:latest

View File

@@ -100,9 +100,10 @@ send_notification() {
####################################### #######################################
run_restic_backup() { run_restic_backup() {
local source_dir="$1" local source_dir="$1"
cd "${source_dir}"
log "Starting backup of '${source_dir}' to repository ${RESTIC_REPOSITORY}" log "Starting backup of '${source_dir}' to repository ${RESTIC_REPOSITORY}"
# Capture both stdout and stderr in a variable # Capture both stdout and stderr in a variable
backup_output=$(restic -r "${RESTIC_REPOSITORY}" backup --no-cache --json --verbose "${source_dir}" 2>&1) backup_output=$(restic -r "${RESTIC_REPOSITORY}" backup --no-cache --json --verbose . 2>&1)
# Optionally, also print the output to the console: # Optionally, also print the output to the console:
echo "$backup_output" echo "$backup_output"
# Parse the JSON lines output for the summary message # Parse the JSON lines output for the summary message