Skip to content

Instantly share code, notes, and snippets.

@fedek6
Last active October 18, 2017 18:10
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 fedek6/d95c5bad57f157288386249c200f88a3 to your computer and use it in GitHub Desktop.
Save fedek6/d95c5bad57f157288386249c200f88a3 to your computer and use it in GitHub Desktop.
Simple backup script for web projects.
#!/bin/sh
# Path
result=${PWD##*/}
# Current date
now=$(date +"%d_%m_%Y")
machine=$(hostname)
# Database credentials
user="developer"
password="****"
host="localhost"
db_name="some_db"
/usr/bin/mysqldump --user=$user --password=$password --host=$host $db_name > ./$db_name-$now.sql
/bin/tar -zcvf ../"${PWD##*/}"-"$machine"-"$now".tar.gz ../"${PWD##*/}"
echo "OK! It's all packed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment