fix: handle permission denied on backup directory
All checks were successful
Deploy to Production / test (push) Successful in 35s

The backups directory may have been created by Docker/root, making it
unwritable by the deploy user. The script now detects this and attempts
to fix permissions automatically (chmod, then sudo chown as fallback).

Also added shared/db/backups to .gitignore.
This commit is contained in:
syntaxbullet
2026-02-13 14:48:06 +01:00
parent 942875e8d0
commit 121c242168
2 changed files with 11 additions and 0 deletions

View File

@@ -29,6 +29,16 @@ echo -e "${YELLOW}💾 Starting database backup...${NC}"
mkdir -p "$BACKUP_DIR"
# Ensure the backup directory is writable (may have been created by Docker/root)
if [ ! -w "$BACKUP_DIR" ]; then
echo -e " ${YELLOW}⚠️ Fixing backup directory permissions...${NC}"
chmod u+w "$BACKUP_DIR" 2>/dev/null || sudo chown "$(whoami)" "$BACKUP_DIR" 2>/dev/null || {
echo -e " ${RED}${NC} Cannot write to $BACKUP_DIR"
echo " Run: sudo chown $(whoami) $BACKUP_DIR"
exit 1
}
fi
if docker ps | grep -q aurora_db; then
# Try to dump the database
if docker exec aurora_db pg_dump -U "${DB_USER:-auroradev}" "${DB_NAME:-auroradev}" > "$BACKUP_FILE"; then