Sign inSign up

mahufong/restic_rclone

By mahufong

•Updated 9 months ago

Image
0

602

mahufong/restic_rclone repository overview

⁠Restic + Rclone

基于 Alpine 的 Restic + Rclone 备份镜像,用于 Kubernetes PV 备份。

⁠镜像信息

  • 基础镜像: Alpine 3.19
  • Restic 版本: 0.16.4
  • Rclone 版本: 1.65.2
  • 支持架构: linux/amd64, linux/arm64

⁠使用方法

⁠拉取镜像
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 使用

在 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
⁠Secret 配置示例
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 - Shell
  • curl - HTTP 客户端

⁠相关链接

Tag summary

Content type

Image

Digest

sha256:2358b353d…

Size

42.7 MB

Last updated

9 months ago

docker pull mahufong/restic_rclone