Documentation Index
Fetch the complete documentation index at: https://xata.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
This contains a sample Kubernetes manifest file for setting up a periodic task to run Xata Clone.
Kubernetes spec
apiVersion: batch/v1
kind: CronJob
metadata:
name: xata-clone
namespace: xata-clone # change if needed
spec:
schedule: "0 0 * * *" # change if needed
jobTemplate:
spec:
template:
spec:
containers:
- name: xata-clone
image: ghcr.io/xataio/xata:latest-pg18
env:
- name: XATA_CLI_SOURCE_POSTGRES_URL
valueFrom:
secretKeyRef:
name: xata-secrets
key: source-postgres-url
- name: XATA_API_KEY
valueFrom:
secretKeyRef:
name: xata-secrets
key: XATA_API_KEY
- name: XATA_ORGANIZATIONID
valueFrom:
secretKeyRef:
name: xata-secrets
key: XATA_ORGANIZATIONID
- name: XATA_PROJECTID
valueFrom:
secretKeyRef:
name: xata-secrets
key: XATA_PROJECTID
- name: XATA_DATABASENAME
valueFrom:
secretKeyRef:
name: xata-secrets
key: XATA_DATABASENAME
- name: XATA_BRANCHID
valueFrom:
secretKeyRef:
name: xata-secrets
key: XATA_BRANCHID
command:
- /bin/bash
- -c
- |
set -e
xata init \
--organization $XATA_ORGANIZATIONID \
--project $XATA_PROJECTID \
--database $XATA_DATABASENAME \
--branch $XATA_BRANCHID
xata status --json
echo "Starting clone..."
xata clone start --source-url "$XATA_CLI_SOURCE_POSTGRES_URL" --validation-mode=relaxed
restartPolicy: OnFailure
Setting up the tasks
Create a dedicated namespace for the task (if you’d like, you can also use an existing one):
kubectl create namespace xata-clone
Step 1: Create secret
The task requires several env variables. Assuming you have the xata CLI already configured on your computer, you can create a secret with all the relevant information like this:
kubectl create secret generic xata-secrets \
--namespace xata-clone \
--from-literal=source-postgres-url="$RDS_URI" \
--from-literal=XATA_API_KEY="$(xata keys organization create)" \
--from-literal=XATA_ORGANIZATIONID="$(xata organization get id)" \
--from-literal=XATA_PROJECTID="$(xata project get id)" \
--from-literal=XATA_BRANCHID="$(xata branch get id)" \
--from-literal=XATA_DATABASENAME="postgres"
The above assumes branch name is main and the database name is postgres, but you should adjust to your case.
Step 2: Create task
Assuming you saved the spec file above as xata-clone-crontask.yaml, you can create it with:
kubectl apply -f xata-clone-crontask.yaml
Step 3: Test the task
Create a test job manually based on the task:
kubectl create job -n xata-clone --from=cronjob/xata-clone xata-clone-manual
And watch the logs:
kubectl logs -l job-name=xata-clone-manual -f -n xata-clone
If there are any errors, you can delete the whole task (kubectl delete -f xata-clone-crontask.yaml), fix the issue, and repeat Step 2.