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")

# Database credentials
user="developer"
password="noodle"
host="localhost"
db_name="retrolove"

# MySQL backup
/usr/bin/mysqldump --user=$user --password=$password --host=$host $db_name > ./$db_name-$now.sql

# Pack whole current dir and create archive one level above
/bin/tar -zcvf ../"${PWD##*/}"-"$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 *