Command-Line Fu: mysqldump | gzip one-liner

Quick MySQL / gzip one-liner for backups, including current date/time filename

For reference, here’s a quick MySQL and gzip one-line terminal command, useful for a scheduled backup

/usr/bin/mysqldump --opt -u <username> -p<password> <DATABASE> | gzip -9 > /data/backup/sql_backup_`date +'%Y%m%d%H%M'`.sql.gz

Notes:

  • gzip -9 is maximum compression
  • date is in the 201801011355’ format (where current date is January 1st 2018 at 1:55pm)

Code Snippets MySQL


Previous post
Command-line Fu: Deleting a remote git branch For reference, delete a remote git branch on origin
Next post
New Gamejam Game: Hey You! Let’s Sword Fight! This past weekend, I participated in “1 Class Jam”. Rather than a themed jam, this jam was a coding challenge. The objective: To create a game in a