Fix: Use disk staging directory instead of tmpfs /tmp for backups

Problem:
- /tmp is a tmpfs mount with only 3.9GB space
- Backing up 1.4TB Nextcloud files requires space for tar and zstd compression
- Both mysqldump and tar were failing with 'No space left on device'

Solution:
- Changed TEMP_DIR from /tmp to /mnt/nextcloud-data/.backup-staging
- /mnt/nextcloud-data has 487GB free space (sufficient for compressed backups)
- Staging directory is automatically cleaned up after successful upload to B2

Impact:
- Backup process now completes successfully for full 1.4TB Nextcloud datasets
- No changes to B2 credentials or configuration
- Backward compatible with existing backup configurations
This commit is contained in:
2026-04-25 19:13:19 -05:00
parent 70dfacddf6
commit 2267a34b47
+4 -1
View File
@@ -17,7 +17,9 @@ BACKUP_DIR="/opt/nextcloud-backup/.backups"
LOG_DIR="${BACKUP_DIR}/logs"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
LOG_FILE="${LOG_DIR}/backup_${TIMESTAMP}.log"
TEMP_DIR="/tmp/nextcloud-backup-${TIMESTAMP}"
# Use staging directory on disk with sufficient space (not tmpfs /tmp)
STAGING_DIR="/mnt/nextcloud-data/.backup-staging"
TEMP_DIR="${STAGING_DIR}/nextcloud-backup-${TIMESTAMP}"
# Create directories
mkdir -p "${BACKUP_DIR}" "${LOG_DIR}" "${TEMP_DIR}"
@@ -84,5 +86,6 @@ fi
# Cleanup
rm -rf "$TEMP_DIR"
rmdir "$STAGING_DIR" 2>/dev/null || true # Remove staging directory if empty
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Backup completed!" | tee -a "${LOG_FILE}"