#!/bin/sh
# First, create a backups directory, under /home/username/
# Then, create a new file named backup_sendy.sh
# Then, paste this text into the backup_sendy.sh and configure the below settings.
# Note that most of the below settings can be found in your /var/www/yourdomain/sendy/includes/config.php file.
# Then, make the backup_sendy.sh script executable with the following command: sudo chmod +x backup_sendy.sh
# Then, try running this shell script with the following command: sudo backup_sendy.sh
# If it works, then you should see backup files in your backup directory.
# If it works, then schedule this script to run in the root user's crontab.

sendydb="sendydbname"                                                       # the name of your Sendy database
mysqlopt='--user=sendyusername --password=sendypassword'                    # the Sendy mysql username and password
sendydir=/var/www/yourdomain/sendy/                                         # the directory that Sendy is installed in
backupdir=/home/username/sendybackups/                                      # the directory to write the backup to
chrset="--default-character-set=yourcharset"                                # The Sendy database charset

mysqldump $chrset --single-transaction $mysqlopt "$sendydb" | gzip > $backupdir/db.$(date +%F.%H%M%S).sql.gz

tar -zcvf $backupdir/sendy_dir_backup.$(date +%F.%H%M%S).tar.gz $sendydir