Last active
January 25, 2021 16:58
-
-
Save lneugebauer/fb46299f767841d6f6b8cb11fd22e8d9 to your computer and use it in GitHub Desktop.
Simple script to backup some directory and MySQL database.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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