-
Notifications
You must be signed in to change notification settings - Fork 4
dev/backup-restore-frappe-data #257
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
Open
brh28
wants to merge
1
commit into
main
Choose a base branch
from
dev/frappe-scripts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Binary file not shown.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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