Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
cron_mysql_backup:
dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular"
keep: 10
max_allowed_packets: 128M # Needs to be larger than the single largest database row
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ TARBALL="$DB_NAME-$(date -Iseconds).sql.bz2"
KEEP=$(({{ database.original.backup.keep | default(cron_mysql_backup.keep) }}+1))

backup(){
mysqldump -u"$DBUSER" -p"$DBPASSWORD" -h"$DBHOST" "$CURRENT_DBNAME" | bzip2 > "$TARGET_DIR/$TARBALL"
mysqldump --max-allowed-packet={{ cron_mysql_backup.max_allowed_packets }} --single-transaction --skip-opt -e --quick \
--skip-disable-keys --skip-add-locks -C -a --add-drop-table \
-u"$DBUSER" -p"$DBPASSWORD" -h"$DBHOST" "$CURRENT_DBNAME" | bzip2 > "$TARGET_DIR/$TARBALL"
ln -sfn "$TARGET_DIR/$TARBALL" "$TARGET_DIR/$DB_NAME"
}

Expand All @@ -23,4 +25,4 @@ cleanup(){
}

backup
cleanup
cleanup