UNTESTED!

backup.sh

#!/bin/bash
PROJECT=domain.com
DBUSR=UserNameThatIsAllowedToUseMYSQLDUMP
DBNAME=NameOfDatabaseOfProject

echo "========= backup database - you will have to provide the password manually"
mysqldump -u "$DBUSR" -p "$DBNAME" > /var/www/vhosts/"$PROJECT"/httpdocs/"$DBNAME".sql
gzip /var/www/vhosts/"$PROJECT"/httpdocs/"$DBNAME".sql;

echo "============== backing up "$PROJECT
tar fcvvvz /var/www/vhosts/"$PROJECT"/backups/"$PROJECT"_files_backup_$(date +%Y-%m-%d-%M).tar.gz /var/www/vhosts/"$PROJECT"/httpdocs

# remove backup again for security reasons
rm -ri /var/www/vhosts/domain.com/httpdocs/NameOfDatabaseOfProject.sql.gz; # here is path handcoded... just to make shure we DO NOT REMOVE ANYTHING ELSE!

HOW TO TEST IT:

cat backup.sh

open up second terminal – copy and paste each line – and run each line of this script – to verify it does what you want.

HAVE PHUN!

WARNING: HOW TO RESTORE

This is using absolute paths… when you untrar this backup it will create those paths (in the current directory)

is if you would untar this backup while beeing in file-root

 / 

it will overwrite your current version of the project. (might what you want but might also not what you want)

admin