backup.yaml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. apiVersion: batch/v1
  2. kind: CronJob
  3. metadata:
  4. name: gdrive-backup
  5. spec:
  6. schedule: "@weekly"
  7. jobTemplate:
  8. spec:
  9. template:
  10. spec:
  11. restartPolicy: "Never"
  12. affinity:
  13. nodeAffinity:
  14. requiredDuringSchedulingIgnoredDuringExecution:
  15. nodeSelectorTerms:
  16. - matchExpressions:
  17. - key: kubernetes.io/arch
  18. operator: In
  19. values:
  20. - amd64
  21. initContainers:
  22. - name: prepare-gdrive-credentials
  23. image: busybox
  24. command: ['sh', '-c', 'cp -R /credentials/* /root/.config/gdrive3']
  25. volumeMounts:
  26. - name: credentials
  27. mountPath: "/credentials/victor.lavaud@gmail.com"
  28. subPath: "victor.lavaud@gmail.com"
  29. - name: accounts
  30. mountPath: "/credentials/accounts.json"
  31. subPath: "accounts.json"
  32. - name: gdrive-config
  33. mountPath: "/root/.config/gdrive3"
  34. containers:
  35. - name: gdrive-backup
  36. image: qdii/backup-gdrive:latest
  37. imagePullPolicy: "Always"
  38. env:
  39. - name: LOCAL_FOLDER_PATH
  40. value: "/tmp/app"
  41. - name: REMOTE_USER
  42. value: "uab10c1ba4bc"
  43. - name: REMOTE_SERVER
  44. value: "bck.dodges.it"
  45. - name: REMOTE_FOLDER_PATH
  46. value: "/home/uab10c1ba4bc/data/vol0/gdrive"
  47. - name: ACCOUNT
  48. value: "victor.lavaud@gmail.com"
  49. volumeMounts:
  50. - name: ephemeral
  51. mountPath: "/tmp/app"
  52. - name: gdrive-config
  53. mountPath: "/root/.config/gdrive3"
  54. - name: backup
  55. mountPath: "/root/.ssh/id_rsa"
  56. subPath: ssh_private_key
  57. - name: backup
  58. mountPath: "/root/.ssh/id_rsa.pub"
  59. subPath: ssh_public_key
  60. volumes:
  61. - name: credentials
  62. projected:
  63. sources:
  64. - secret:
  65. name: gdrive
  66. items:
  67. - key: secret.json
  68. path: "victor.lavaud@gmail.com/secret.json"
  69. - key: tokens.json
  70. path: "victor.lavaud@gmail.com/tokens.json"
  71. - name: accounts
  72. secret:
  73. secretName: gdrive
  74. items:
  75. - key: accounts.json
  76. path: "accounts.json"
  77. - name: backup
  78. secret:
  79. secretName: backup
  80. defaultMode: 0400
  81. - name: ephemeral
  82. emptyDir:
  83. sizeLimit: 50Gi
  84. - name: gdrive-config
  85. emptyDir:
  86. sizeLimit: 10Mi