基于 Alpine 的 Restic + Rclone 备份镜像,用于 Kubernetes PV 备份。
docker pull mahufong/restic_rclone:latest
# 查看版本
docker run --rm mahufong/restic_rclone restic version
docker run --rm mahufong/restic_rclone rclone version
# 使用 rclone 后端进行备份
docker run --rm \
-e RESTIC_REPOSITORY="rclone:myremote:path/to/repo" \
-e RESTIC_PASSWORD="your-password" \
-v ~/.config/rclone/rclone.conf:/root/.config/rclone/rclone.conf:ro \
-v /data:/data:ro \
mahufong/restic_rclone \
restic backup /data
在 Kubernetes 中使用此镜像备份 PVC:
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup-pvc
spec:
schedule: "0 2 */3 * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: mahufong/restic_rclone:latest
envFrom:
- secretRef:
name: restic-credentials
command:
- /bin/sh
- -c
- |
# 写入 rclone 配置
mkdir -p /root/.config/rclone
echo "$RCLONE_CONFIG_CONTENT" > /root/.config/rclone/rclone.conf
# 执行备份
restic backup --host k8s-myapp --tag k8s /data
restic forget --keep-last 5 --keep-daily 7 --prune
volumeMounts:
- name: data
mountPath: /data
readOnly: true
volumes:
- name: data
persistentVolumeClaim:
claimName: my-pvc
apiVersion: v1
kind: Secret
metadata:
name: restic-credentials
type: Opaque
stringData:
RESTIC_REPOSITORY: "rclone:openList:aliyun/备份/restic/k8s"
RESTIC_PASSWORD: "your-restic-password"
RCLONE_CONFIG_CONTENT: |
[openList]
type = webdav
url = https://your-webdav-server/dav
vendor = other
user = your-username
pass = your-encrypted-password
restic - 快速、安全的备份程序rclone - 云存储同步工具bash - Shellcurl - HTTP 客户端Content type
Image
Digest
sha256:2358b353d…
Size
42.7 MB
Last updated
9 months ago
docker pull mahufong/restic_rclone