Skip to content

Instantly share code, notes, and snippets.

@integrii
Last active May 18, 2022 04:05
Show Gist options
  • Save integrii/04d947a8577173fbd355cbe374c0a923 to your computer and use it in GitHub Desktop.
Save integrii/04d947a8577173fbd355cbe374c0a923 to your computer and use it in GitHub Desktop.

Revisions

  1. integrii revised this gist May 18, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions restic-backup-cronjob-synapse.yaml
    Original file line number Diff line number Diff line change
    @@ -53,8 +53,8 @@ spec:
    apiVersion: v1
    data:
    config: |
    Host de1932.rsync.net
    User de1932
    Host <rsync.net user>.rsync.net
    User <rsync.net user>
    IdentityFile /ssh/id_rsa
    StrictHostKeyChecking no
    kind: ConfigMap
  2. integrii created this gist May 18, 2022.
    72 changes: 72 additions & 0 deletions restic-backup-cronjob-synapse.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@
    apiVersion: batch/v1beta1
    kind: CronJob
    metadata:
    name: restic-backup-synapse
    namespace: synapse
    spec:
    schedule: "0 4 * * *"
    concurrencyPolicy: Forbid
    successfulJobsHistoryLimit: 3
    failedJobsHistoryLimit: 3
    jobTemplate:
    spec:
    backoffLimit: 2
    template:
    spec:
    nodeName: k8s-worker5
    volumes:
    - name: host
    hostPath:
    path: /
    type: Directory
    - name: ssh-private-key
    secret:
    secretName: restic-ssh-private-key
    items:
    - key: id_rsa
    mode: 0400
    path: id_rsa
    - name: ssh-config
    configMap:
    name: ssh-config
    restartPolicy: Never
    containers:
    - name: restic
    image: restic/restic
    env:
    - name: RESTIC_PASSWORD
    value: “<restic repo password>“
    - name: RESTIC_REPOSITORY
    value: "sftp:<rsync.net user>@<rsync.net user>.rsync.net:garage/synapse"
    command: ["restic", "backup", "--verbose", "--limit-upload=610", "--no-cache", "/host/synapse"]
    volumeMounts:
    - mountPath: /host
    name: host
    - mountPath: /ssh
    name: ssh-private-key
    - mountPath: /root/.ssh
    name: ssh-config
    securityContext:
    privileged: true
    runAsUser: 0
    ---
    apiVersion: v1
    data:
    config: |
    Host de1932.rsync.net
    User de1932
    IdentityFile /ssh/id_rsa
    StrictHostKeyChecking no
    kind: ConfigMap
    metadata:
    name: ssh-config
    namespace: synapse
    ---
    apiVersion: v1
    kind: Secret
    metadata:
    name: restic-ssh-private-key
    namespace: synapse
    type: Opaque
    data:
    id_rsa: <base64 private key>