frappe_docker/backup.sh
Tushar 56cef5fe68 feat: add backup and email configuration scripts and environment files
- Introduced backup scripts for S3 and Google Drive, including cron job setup for automated backups.
- Added email configuration script to set up SMTP settings for ERPNext.
- Created environment files for backup configurations (backup.env, gdrive-backup.env, email.env).
- Updated docker-compose files to support new backup services and configurations.
2025-03-20 10:44:25 +00:00

26 lines
No EOL
1.2 KiB
Bash
Executable file

#!/bin/bash
# Path to your docker-compose files
COMPOSE_FILES="-f compose.yaml -f overrides/compose.mariadb.yaml -f overrides/compose.redis.yaml -f overrides/compose.https.yaml"
# Create backup with files
docker compose $COMPOSE_FILES exec backend bench --site all backup --with-files
# Optional: Copy backups to a local directory outside the Docker volume
# Create a backups directory if it doesn't exist
mkdir -p ./backups
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
docker compose $COMPOSE_FILES exec backend mkdir -p /home/frappe/frappe-bench/backups-export
docker compose $COMPOSE_FILES exec backend cp -r /home/frappe/frappe-bench/sites/*/backup/* /home/frappe/frappe-bench/backups-export/
# Copy the backups from the container to the host
docker compose $COMPOSE_FILES cp backend:/home/frappe/frappe-bench/backups-export/ ./backups/$TIMESTAMP
# Cleanup the temporary directory in the container
docker compose $COMPOSE_FILES exec backend rm -rf /home/frappe/frappe-bench/backups-export
echo "Backup completed at ./backups/$TIMESTAMP"
# Optional: Implement backup rotation/cleanup to prevent using too much disk space
# Keep only the last 7 days of backups
find ./backups -type d -mtime +7 -exec rm -rf {} \; 2>/dev/null || true