update: safety first!

when it comes to important files: safety comes first

thus recommend to the user that wants to go pro the following backup system:

  • have two complete backups at two different places:
    • backupA: at the company, USB 3.0 (! THE MORE DATA IS BACKED UP THE MORE SPEED IS NEEDED (or restore might take DAYS!)) connected to the server, doing daily incremental backups
    • backupB: being a fire-proof double-metal casing (EMP proof) vault at a different place (home?)
  • change those backups every day if possible otherwise every week
    • if ransomeware destroys backupA then in the worst case scenario, one day or one week of work is gone
    • remember: whatever is physically connected to the server, can be encrypted by ransomeware
  • have the backup strategy tested once a year
    • where the backup is restored completely on a backup-server, to test if all data is there and how long the process takes (USB 2.0 is definitely a massive bottleneck)

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)

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin