Skip to content

Instantly share code, notes, and snippets.

@eftakhairul
Last active September 14, 2018 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eftakhairul/3b596055399480012d5f3f83dc2d22e8 to your computer and use it in GitHub Desktop.
Save eftakhairul/3b596055399480012d5f3f83dc2d22e8 to your computer and use it in GitHub Desktop.
Dump your db using bzip2 compression
#!/bin/sh
# Creates database backups using mysqldump. It uses bzip2 for compression, and
# the filename of the dump is DB- and the current timestamp. The dumps are stored
# in ARCHIVE_DIR and bzip2 is called with nice to make it softer on the server.
ARCHIVE_DIR=~/backup
FILENAME=$(date '+%Y-%m-%d_%H:%M:%S')
USER=root
PASS=your_db_password
OPTIONS="-A -e"
mysqldump $OPTIONS -u $USER -p$PASS | nice bzip2 -9 > $ARCHIVE_DIR/DB-$FILENAME.sql.bz2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment