This repository contians bash scripts and GitHub Actions workflows to backup and restore Bookstack nad its MySQL deployed on a Microk8s cluster using this Helm chart.
-
Make sure kubectl is installed, the current context is configured, and it can connect to the cluster successfully.
-
The following environment variables are set:
export KUBE_CONTEXT="microk8s" export WIKI_NAMESPACE="wiki" export MYSQL_APP_LABEL="release-mysql" export BOOKSTACK_APP_LABEL="release-bookstack"
Execute the script.
source <(curl -s https://raw.githubusercontent.com/pacroy/bookstack-backup/main/backup.sh)If you copyback from one environment to another, you can additionally set the following variables to update all links.
export HOST_FROM="wiki.yourdomain.com"
export HOST_TO="wiki2.yourdomain.com"Execute the script.
bash -e <(curl -s https://raw.githubusercontent.com/pacroy/bookstack-backup/main/restore.sh)- Create AzureAD application, if you don't already have one.
- Grant the application so it can access storage account.
- Configure OIDC federated credential in your application to allow GitHub Actions to acess your Azure environment.
- Fork or clone this repository into yours.
- Go to your repository settings and create a new environment
production. - Add the following environment secrets:
| Name | Description |
|---|---|
| AZURE_CLIENT_ID | AzureAD application client ID |
| AZURE_SUBSCRIPTION_ID | Azure subscription ID |
| AZURE_TENANT_ID | Azure tenant ID |
| BLOB_CONTAINER_NAME | Blob container name within Azure storage for storing backup files |
| BOOKSTACK_APP_LABEL | Bookstack pod label e.g. release-bookstack |
| KUBE_API_SERVER | Kubeconfig clusters.cluster.server |
| KUBE_CA_BASE64 | Kubeconfig clusters.cluster.certificate-authority-data |
| KUBE_CONTEXT | Kubeconfig contexts.context.name |
| KUBE_USER_TOKEN | Kubeconfig users.user.token |
| MYSQL_APP_LABEL | MySQL pod label e.g. release-mysql |
| SENDGRID_API_KEY | SendGrid API Key for sending email notification |
| SENDGRID_RECIPIENTS | Recipient email address(es), separated by semicolon |
| SENDGRID_SENDER | Verified sender email address |
| STORAGE_ACCOUNT_NAME | Azure storage account name for storing backup files |
| WIKI_NAMESPACE | Kubernetes namespace containing bookstack release |
- The
Backupworkflow is configured to run every Sunday's 0:00. You can also manually run it at anytime you want.
- Go to your repository settings and create a new environment you want to restore to.
- Add the following environment secrets:
| Name | Description |
|---|---|
| AZURE_CLIENT_ID | AzureAD application client ID |
| AZURE_SUBSCRIPTION_ID | Azure subscription ID |
| AZURE_TENANT_ID | Azure tenant ID |
| BLOB_CONTAINER_NAME | Blob container name within Azure storage for downloading backup files |
| BOOKSTACK_APP_LABEL | Bookstack pod label e.g. release-bookstack |
| KUBE_API_SERVER | Kubeconfig clusters.cluster.server |
| KUBE_CA_BASE64 | Kubeconfig clusters.cluster.certificate-authority-data |
| KUBE_CONTEXT | Kubeconfig contexts.context.name |
| KUBE_USER_TOKEN | Kubeconfig users.user.token |
| MYSQL_APP_LABEL | MySQL pod label e.g. release-mysql |
| STORAGE_ACCOUNT_NAME | Azure storage account name for downloading backup files |
| WIKI_NAMESPACE | Kubernetes namespace containing bookstack release |
| UPDATE_HOST_FROM | Optional. Domain to search in the URLs. |
| UPDATE_HOST_TO | Optional. Domain to replace in the URLs. |
- Run the workflow
Restoreand input backup date e.g.20231008and environment name to restore.