Skip to content

Instantly share code, notes, and snippets.

@lneugebauer
Last active January 25, 2021 16:58
Show Gist options
  • Save lneugebauer/fb46299f767841d6f6b8cb11fd22e8d9 to your computer and use it in GitHub Desktop.
Save lneugebauer/fb46299f767841d6f6b8cb11fd22e8d9 to your computer and use it in GitHub Desktop.
Simple script to backup some directory and MySQL database.
#! /bin/bash
date=$(date +"%y%m%d-%H%M%S")
dir="~/foo/bar/" # with trailing slash
project="foo.bar"
db="foo"
db_user="bar"
echo "Creating archive ..."
tar -czf ${date}_${project}.tgz ${dir}${project} >/dev/null 2>&1
echo "Created archive of "${dir}${project}
echo "Creating database dump ..."
mysqldump --single-transaction -u${db_user} -p ${db} > ${date}_${project}.sql
gzip ${date}_${project}.sql
echo "Created database dump of "${db}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment