Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Helm/Kubernetes] Add Documentation / Examples for Backup / Restoring. #886

Open
XtremeOwnageDotCom opened this issue Mar 8, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@XtremeOwnageDotCom
Copy link

A simple request to update the documentation to add kubernetes-specific examples for backing up data, and restoring data.

I have example scripts which I created for the purposes of backing up and restoring my own instance.

Backup Script / Commands

#!/bin/bash

# Namespace which contains part-db
NAMESPACE="part-db"

# The container's name (Not POD!) This... shouldn't change.
CONTAINER_NAME="part-db"

# The name of the pod. This, will change depending on your release.
POD_NAME="parts-db-part-db-0"

# Path inside of the container where the backup will be created
CONTAINER_BACKUP_PATH="/tmp/partsdb_backup.zip"

# Where we want to store the resulting backup. (Relative to current directory)
BACKUP_DESTINATION="mybackup.zip"


kubectl exec -it -n $NAMESPACE -c $CONTAINER_NAME $POD_NAME -- php bin/console partdb:backup --full $CONTAINER_BACKUP_PATH
kubectl cp       -n $NAMESPACE -c $CONTAINER_NAME $POD_NAME:$CONTAINER_BACKUP_PATH $BACKUP_DESTINATION

Restore Script / Commands

#!/bin/bash

# Backup file relative to current directory. (partsdb.zip exists in my current directory)
BACKUP_FILE="partsdb.zip"

# Namespace which contains part-db
NAMESPACE="part-db"
# The container's name (Not POD!) This... shouldn't change.
CONTAINER_NAME="part-db"
# The name of the pod. This, will change depending on your release.
POD_NAME="parts-db-part-db-0"


# Shouldn't need to touch these.
CONTAINER_BACKUP_FOLDER="/var"
CONTAINER_BACKUP_FILE=$BACKUP_FILE
CONTAINER_BACKUP_EXTRACTED="/var/extracted_backups"

# Copy backup .zip into container
kubectl cp -n $NAMESPACE -c $CONTAINER_NAME $BACKUP_FILE $POD_NAME:$CONTAINER_BACKUP_FOLDER/$CONTAINER_BACKUP_FILE

# Extract backup files to $CONTAINER_BACKUP_EXTRACTED
kubectl exec -it -n $NAMESPACE -c $CONTAINER_NAME $POD_NAME -- unzip $CONTAINER_BACKUP_FOLDER/$CONTAINER_BACKUP_FILE -d $CONTAINER_BACKUP_EXTRACTED

# Restore Public/Media
kubectl exec -it -n $NAMESPACE -c $CONTAINER_NAME $POD_NAME -- cp -R $CONTAINER_BACKUP_EXTRACTED/public/media /var/www/html/public

# Overwrite database file.
kubectl exec -it -n $NAMESPACE -c $CONTAINER_NAME $POD_NAME -- cp $CONTAINER_BACKUP_EXTRACTED/var/app.db /var/www/html/var/db

# Delete POD. (Aka, Restart Part-DB)
kubectl delete pod -n $NAMESPACE $POD_NAME
@XtremeOwnageDotCom XtremeOwnageDotCom added the enhancement New feature or request label Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant