Hi All,
So, I chose my host (Pair Networks) because it runs FreeBSD. However, I am a total beginner, so you can throw stones at me, because my question is stupid, but this problem keeps me from moving forward.
In fact, my script works with a very convoluted code, but I want to simplify it.
Here is my problem: I need to backup, zip and encrypt my databases to finally send them to a mailbox.
Here is the bash script. In fact, the variable declaration does not work. Thank you for your help.
So, I chose my host (Pair Networks) because it runs FreeBSD. However, I am a total beginner, so you can throw stones at me, because my question is stupid, but this problem keeps me from moving forward.
In fact, my script works with a very convoluted code, but I want to simplify it.
Here is my problem: I need to backup, zip and encrypt my databases to finally send them to a mailbox.
Here is the bash script. In fact, the variable declaration does not work. Thank you for your help.
Code:
#!/bin/sh
# Pair Database Server URL:
SERVERDB='dbXYZ.pair.com'
# Database User Name:
USERDB='ABC_20'
# Database Password:
PASSDB='X1Y2Z3'
# Database Name:
DBNAME='POL_40'
#####
# Path to Backup directory:
PATH='/usr/home/USERNAME/public_html/Backup'
# Password to encrypt Database Before Sending it by email (Do NOT use semi-colon ";"):
OPENPASS='%4957I@6IcrV'
# Email address where send to the Backuped, Zipped and Encrypted Database:
EMAIL='me@mail.com'
# Email Subject (date and time is added at the end of this subject):
SUBJECT='POL_40 Backup'
# Delete the Zipped Backups Databases Older than n Day:
DAYS=1
##############################
# #
# NO Change Under This Box #
# #
##############################
DATE=`date +\%Y-\%m-\%d-at-\%H:\%M:\%S`
/usr/local/bin/mysqldump -h$SERVERDB -u$USERDB -p$PASSDB $DBNAME | gzip -9 > $PATH/$DBNAME-$DATE.sql.gz
openssl enc -aes-256-cbc -salt -a -in $PATH/$DBNAME-$DATE.sql.gz -out $PATH/$DBNAME-$DATE.sql.gz.ENC -pass pass:$PASS
/usr/local/bin/mutt -s "$SUBJECT $DATE" -a $PATH/$DBNAME-$DATE.sql.gz.ENC -- $EMAIL > /dev/null
rm $PATH/$DBNAME-$DATE.sql.gz.ENC
find $PATH/$DBNAME-*.sql.gz -mtime +$DAYS -exec rm {} \;