Scripts that I use for TrueNAS jail cron jobs to backup my Azure Kubernetes Service data.
For Ubuntu Server 22.04.2 LTS the following packages are additionally required:
kubectl
, see Install and Set Up kubectl on Linuxsudo apt install nfs-common
Add the following with crontab -e
to run the backup scripts daily at 02:30 AM:
KUBECONFIG=/mnt/backup-k8s/.kube/config
REMARK_BACKUP_DIR=/mnt/backup-k8s/remark42
REMARK_LABEL=app=remark42
REMARK_NAMESPACE=remark42
30 2 * * * /mnt/backup-k8s/scripts/backup-remark42.sh >/mnt/backup-k8s/log/remark42.txt 2>&1
POSTGRES_LABEL=app=postgres
POSTGRES_NAMESPACE=postgres
MATRIX_NAMESPACE=matrix
MATRIX_SYNAPSE_BACKUP_DIR=/mnt/backup-k8s/matrix-synapse
MATRIX_SYNAPSE_DB=matrix-synapse
MATRIX_SYNAPSE_LABEL=app=matrix-synapse
30 2 * * * /mnt/backup-k8s/scripts/backup-matrix-synapse.sh >/mnt/backup-k8s/log/matrix-synapse.txt 2>&1
PLAUSIBLE_BACKUP_DIR=/mnt/backup-k8s/plausible
PLAUSIBLE_DB=plausible
PLAUSIBLE_EVENT_DATA_LABEL=app=event-data
PLAUSIBLE_NAMESPACE=plausible
30 2 * * * /mnt/backup-k8s/scripts/backup-plausible.sh >/mnt/backup-k8s/log/plausible.txt 2>&1
Set environment variables in /etc/environment
alternatively.
setenv KUBECONFIG /mnt/backup-k8s/.kube/config
setenv REMARK_BACKUP_DIR /mnt/backup-k8s/remark42
setenv REMARK_LABEL app=remark42
setenv REMARK_NAMESPACE remark42
./restore-remark42.sh
setenv POSTGRES_LABEL app=postgres
setenv POSTGRES_NAMESPACE postgres
setenv MATRIX_NAMESPACE matrix
setenv MATRIX_SYNAPSE_BACKUP_DIR /mnt/backup-k8s/matrix-synapse
setenv MATRIX_SYNAPSE_DB matrix-synapse
setenv MATRIX_SYNAPSE_LABEL app=matrix-synapse
./restore-matrix-synapse.sh
setenv PLAUSIBLE_BACKUP_DIR /mnt/backup-k8s/plausible
setenv PLAUSIBLE_DB plausible
setenv PLAUSIBLE_EVENT_DATA_LABEL app=event-data
setenv PLAUSIBLE_NAMESPACE plausible
./restore-plausible.sh