A Docker image for periodical backups of Laravel's storage/app
folder to Google Cloud Storage.
- Create Kubernetes secret containing the GC service account JSON key:
kubectl create secret generic laravel-storage-gc-backup \
--from-file=gc-service-account.json=/path/to/keyfile.json
- Add a new sidecar container to the existing Laravel image deployment:
containers:
- name: laravel-storage-gc-backup
image: dazlabteam/laravel-storage-gc-backup
imagePullPolicy: Always
env:
- name: GCS_BUCKET
value: <GC bucket name>
volumeMounts:
- name: gc-service-account
readOnly: true
mountPath: /gc-service-account.json
subPath: gc-service-account.json
volumes:
- name: gc-service-account
secret:
secretName: laravel-storage-gc-backup
By default, it will run every day at 00:00. To change this, specify CRON_EXPR
env variable:
image: dazlabteam/laravel-storage-gc-backup
env:
- name: CRON_EXPR
value: 0 1 * * *
The two variables can be specified for setting the custom storage path and a custom prefix for a resulting backup archive:
image: dazlabteam/laravel-storage-gc-backup
env:
- name: BACKUP_PATH
value: /path/to/laravel/storage
- name: BACKUP_PREFIX
value: my-custom-archive
image: dazlabteam/laravel-storage-gc-backup
env:
- name: GCS_KEY_FILE_PATH
value: /my-system-account.json
MIT