Backup www folder and Database into single tar.gz file run every 2Am at Saturday

mkdir /backup
echo "[client]
user=user
password=your_pass" > /etc/mysql/mysqldump.cnf

Backup Script

vi /opt/backup.sh
#!/bin/bash
#run: /opt/backup.sh sitename_in_var_www DB_name
SITE=$1
DB=$2
TIME=$(date +"%d-%m-%Y")
FILE="$SITE.$TIME.tar"
BACKUP_DIR="/backup"
WWW_DIR="/var/www/$SITE"
DB_NAME="$DB"
DB_FILE="$DB.$TIME.sql"
WWW_TRANSFORM="s,^var/www/$SITE,www,"
DB_TRANSFORM="s,^backup,database,"
tar -cvf $BACKUP_DIR/$FILE --transform $WWW_TRANSFORM $WWW_DIR
mysqldump --defaults-file=/etc/mysql/mysqldump.cnf $DB_NAME > $BACKUP_DIR/$DB_FILE
tar --append --file=$BACKUP_DIR/$FILE --transform $DB_TRANSFORM $BACKUP_DIR/$DB_FILE
rm $BACKUP_DIR/$DB_FILE
gzip -9 $BACKUP_DIR/$FILE
exit 0

Make it executable

chmod 700 /opt/backup.sh

Manually run

/opt/backup.sh site_name site_database
Verify content
tar -ztvf /backup/sitename.02-10-2015.tar.gz

Crontab Schedule: backup wordpress @2AM every Saturday

crontab -e
00 2 * * 5 /opt/backup.sh site_name site_database >/dev/null 2>&1

Reference: https://jay-baker.com/wordpress-automated-backup-script-with-rsync-and-systemd/