Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ start-deps:
docker compose up bats-deps -d

start-frappe:
docker compose up frappe -d
./dev/erpnext/start.sh

clean-frappe:
./dev/clean-frappe
stop-frappe:
docker compose down frappe

reset-frappe:
./dev/erpnext/clean.sh
./dev/erpnext/start.sh
@echo "Waiting for frappe to initialize..."
@sleep 60
./dev/erpnext/restore.sh dev/erpnext/backups/20260123_132015-frontend-database.sql.gz

start-deps-integration:
docker compose up integration-deps -d
Expand Down
17 changes: 17 additions & 0 deletions dev/erpnext/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Create backups directory on host if it doesn't exist
BACKUP_DIR="$(dirname "$0")/backups"
mkdir -p "$BACKUP_DIR"

docker exec -it flash-frappe-frontend-1 mkdir -p /tmp/backups

# Run the backup inside the container and capture output
BACKUP_OUTPUT=$(docker exec flash-frappe-frontend-1 bench --site frontend backup --backup-path /tmp/backups)

# Extract the database path from the output line containing "Database:"
BACKUP_FILE=$(echo "$BACKUP_OUTPUT" | grep "Database:" | awk '{print $2}')
echo $BACKUP_FILE
docker cp flash-frappe-frontend-1:$BACKUP_FILE "$BACKUP_DIR/"

echo "Backups saved to: $BACKUP_DIR"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to store the actual backup in the git history?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the backup contains the data required for features like cashout, so we definitely want it somewhere. We could reference an external source, but not sure what this would gain. I think git is fine... just want to make sure we're not checking in multiple versions which would be confusing

Binary file not shown.
File renamed without changes.
27 changes: 27 additions & 0 deletions dev/erpnext/restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Check if backup file is provided as argument
if [ -z "$1" ]; then
echo "Usage: $0 <backup-file.sql.gz>"
echo "Example: $0 backups/20260122_062420-frontend-database.sql.gz"
exit 1
fi

BACKUP_FILE="$1"
DB_PASSWORD="admin" # defined in docker compose

# Check if backup file exists
if [ ! -f "$BACKUP_FILE" ]; then
echo "Error: Backup file '$BACKUP_FILE' not found"
exit 1
fi

# Get just the filename from the path
BACKUP_FILENAME=$(basename "$BACKUP_FILE")

# Copy the backup file from host to container restore directory
docker exec -it flash-frappe-frontend-1 mkdir -p /tmp/restore
docker cp "$BACKUP_FILE" flash-frappe-frontend-1:/tmp/restore/"$BACKUP_FILENAME"

# Restore the database inside the container with the password
docker exec -it flash-frappe-frontend-1 bench --site frontend restore --db-root-password "$DB_PASSWORD" /tmp/restore/"$BACKUP_FILENAME"
7 changes: 7 additions & 0 deletions dev/erpnext/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

docker compose up frappe -d

echo "Login to http://frontend.local:8080/#login"
echo "Username: Administrator"
echo "Password: admin"