Simple backup script for your web projects

If you want to archive your project quickly with additional MySQL dump you can use this simple Bash script.


File: backup.sh
---------------

#!/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."

Published by

Konrad Fedorczyk

Konrad Fedorczyk

I'm interested in programming and gamedev. I especially luv HTML5 and everything connected to web technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *