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!

A GOOD WAY TO TEST:

cat backup.sh

is to run this script is to actually run it line by line and see if it’s what you want that happens…

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