{"id":19686797,"url":"https://github.com/donaldkellett/kanister-wordpress","last_synced_at":"2026-04-20T10:33:02.434Z","repository":{"id":243447658,"uuid":"812458464","full_name":"DonaldKellett/kanister-wordpress","owner":"DonaldKellett","description":"Back up and restore WordPress on Kubernetes with Kanister","archived":false,"fork":false,"pushed_at":"2024-06-09T05:45:34.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-10T08:47:10.960Z","etag":null,"topics":["aws","kanister","kubernetes","wordpress"],"latest_commit_sha":null,"homepage":"https://www.donaldsebleung.com/blog/20240609-protecting-stateful-workloads-on-kubernetes-with-kanister","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DonaldKellett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-09T00:26:25.000Z","updated_at":"2024-06-09T10:34:03.000Z","dependencies_parsed_at":"2024-06-09T01:45:05.702Z","dependency_job_id":"120d204b-046e-4e4f-b505-5f5ac40beca6","html_url":"https://github.com/DonaldKellett/kanister-wordpress","commit_stats":null,"previous_names":["donaldkellett/kanister-wordpress"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DonaldKellett/kanister-wordpress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonaldKellett%2Fkanister-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonaldKellett%2Fkanister-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonaldKellett%2Fkanister-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonaldKellett%2Fkanister-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DonaldKellett","download_url":"https://codeload.github.com/DonaldKellett/kanister-wordpress/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonaldKellett%2Fkanister-wordpress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32043051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","kanister","kubernetes","wordpress"],"created_at":"2024-11-11T18:30:25.710Z","updated_at":"2026-04-20T10:33:02.417Z","avatar_url":"https://github.com/DonaldKellett.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kanister-wordpress\n\nBack up and restore WordPress on Kubernetes with Kanister\n\n## Overview\n\n[Kubernetes CSI](https://kubernetes-csi.github.io/docs/) enables us to take volume snapshots on supported storage backends as a first step towards protecting our data on Kubernetes but snapshots operate at the infrastructure level so they do not understand how applications operate and manage their data. This implies that snapshots, by nature, are crash-consistent but not application-consistent. For busy stateful workloads such as databases processing many transactions per second, crash-consistency is insufficient for data protection since in-progress transactions are not recorded so restoring from a snapshot may still lead to data loss and leave the application in a broken state.\n\n[Kanister](https://kanister.io/) provides a robust and flexible solution for defining your own actions for performing application-aware backups on Kubernetes. It does this by defining blueprints, which serve as templates for application-specific backup and restore actions. The backup administrator or application owner may then instantiate actions defined in these blueprints by creating ActionSets which perform the actual application-specific backup and recovery tasks.\n\nThis demo demonstrates how to back up and restore WordPress on Kubernetes with Kanister in a reliable manner, by creating a logical database backup \\(database dump\\) and exporting it to S3 which can be imported during the restore phase to return WordPress to a known good state. The backup procedure consists of the following 3 steps:\n\n1. Scale the WordPress deployment to zero to stop accepting user traffic and complete pending database transactions\n1. Take a logical dump of the database and upload it to S3\n1. Scale the WordPress deployment back to the original count to start accepting user traffic again\n\nThe restore procedure is also similar:\n\n1. Scale the WordPress deployment to zero to stop accepting user traffic and ensure no additional database transactions are made during the restore operation\n1. Download the logical database dump from S3 and import it to our running database\n1. Scale the WordPress deployment back to the original count to start accepting user traffic again\n\n## Developing\n\nFork and clone this repository, then navigate to the project root and follow the instructions below.\n\n### Install pre-commit hook \\(optional\\)\n\nThe pre-commit hook runs formatting and sanity checks such as `tofu fmt` to reduce the chance of accidentally submitting badly formatted code that would fail CI.\n\n```bash\nln -s ../../hooks/pre-commit ./.git/hooks/pre-commit\n```\n\n### Prerequisites\n\n1. An [AWS](https://aws.amazon.com/) account\n1. Valid AWS credentials for an IAM administrator account - see [Configure the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) for details\n1. [OpenTofu](https://opentofu.org/) v1.7.2 or later\n1. A Kubernetes cluster - spin one up with [kind](https://kind.sigs.k8s.io/) if in doubt\n1. Cluster-admin access to the Kubernetes cluster with `kubectl`\n1. [Helm](https://helm.sh/)\n1. WordPress installed in the `wordpress` namespace with release name `wordpress` within your cluster via the Bitnami [Helm chart](https://artifacthub.io/packages/helm/bitnami/wordpress)\n1. The [Kanister operator](https://docs.kanister.io/install.html) installed on our Kubernetes cluster\n1. [Go](https://go.dev/) 1.22.4 or above\n1. The [Kanister tools](https://docs.kanister.io/tooling.html) installed\n\n### Create the S3 bucket for storing our Kanister backups\n\nCreate the S3 bucket for storing our Kanister backups using OpenTofu:\n\n```bash\ntofu init\ntofu plan\ntofu apply\n```\n\nSupported variables:\n\n| Name | Type | Required | Default value | Description |\n| --- | --- | --- | --- | --- |\n| `profile` | `string` | - | `\"default\"` | The profile to assume from the [AWS credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) |\n| `region` | `string` | - | `\"ap-east-1\"` | The AWS region to assume |\n\n### Back up our WordPress database to S3\n\nThis demo is adapted from the [MariaDB Kanister example](https://github.com/kanisterio/kanister/tree/master/examples/maria).\n\nFirst create the blueprint:\n\n```bash\nkubectl create -f manifests/blueprint.yaml\n```\n\nCreate a location profile and corresponding secret as well to point to our S3 bucket where we'll store our database dumps to.\n\n```bash\nkubectl create -f manifests/secret.yaml\nkubectl create -f manifests/profile.yaml\n```\n\nNow run the `quiesce` action with `kanctl` which scales down our WordPress deployment to zero. This ensures that we are not writing to the database when the backup occurs at a later stage.\n\n```bash\nkanctl -n kanister create actionset \\\n    --action quiesce \\\n    --blueprint wordpress-bp \\\n    --deployment wordpress/wordpress\n```\n\nSample output:\n\n```text\nactionset quiesce-spx9q created\n```\n\nNow we can run the `backup` action to backup up our WordPress database:\n\n```bash\nkanctl -n kanister create actionset \\\n    --action backup \\\n    --blueprint wordpress-bp \\\n    --profile wordpress-s3-profile \\\n    --statefulset wordpress/wordpress-mariadb\n```\n\nSample output:\n\n```text\nactionset backup-pzxzz created\n```\n\nOnce the backup is complete, run the `unquiesce` action which scales our WordPress deployment back to the original number of replicas so it can start accepting user traffic again.\n\n```bash\nQUIESCE_ACTIONSET=\"quiesce-spx9q\" # Replace me!\nkanctl -n kanister create actionset \\\n    --action unquiesce \\\n    --from \"${QUIESCE_ACTIONSET}\"\n```\n\n### Restore our WordPress database from S3\n\nAs with backing our our WordPress database to S3, we should quiesce our WordPress application as well prior to restoring from our database dump:\n\n```bash\nkanctl -n kanister create actionset \\\n    --action quiesce \\\n    --blueprint wordpress-bp \\\n    --deployment wordpress/wordpress\n```\n\nSample output:\n\n```text\nactionset quiesce-2jtgj created\n```\n\nNow run the `restore` action to restore our WordPress database from the SQL dump uploaded to S3:\n\n```bash\nBACKUP_ACTIONSET=\"backup-pzxzz\" # Replace me!\nkanctl -n kanister create actionset \\\n    --action restore \\\n    --from \"${BACKUP_ACTIONSET}\"\n```\n\nOnce the restore operation is complete, unquiesce our WordPress application so it can start accepting user traffic again:\n\n```bash\nQUIESCE_ACTIONSET=\"quiesce-2jtgj\" # Replace me!\nkanctl -n kanister create actionset \\\n    --action unquiesce \\\n    --from \"${QUIESCE_ACTIONSET}\"\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonaldkellett%2Fkanister-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonaldkellett%2Fkanister-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonaldkellett%2Fkanister-wordpress/lists"}