UnixServerAdmin

Server Administration & Management

backup_dump_encrypt.sh (in tar.gz format)

#############################################################################
# Database Server Backup ############################################################
# backup_dump_encrypt.sh (in-tar.gz-format) script #############################################
#############################################################################
#!/bin/sh
set -x
set -v
standby=$1
myfirstfile=”Testing_Backup`date +’%d-%b-%Y-%H-%M’`.sql”
myfile=”Testing_Backup`date +’%d-%b-%Y-%H-%M’`.sql.tar.gz”

# mysql dump, check, scp and report
mysqldump -uroot -pPASSWORD –all-databases –routines –flush-logs –single-transaction –master-data=2 > /backup/mysqldump/$myfirstfile 2> /backup/mysqldump/ORS_err.txt
cd /backup/mysqldump/

tar -zcvf – $myfirstfile | openssl enc -aes-256-cbc -pass pass:ABCabc123@  -e | dd of=/backup/mysqldump/$myfirstfile.tar.gz.enc
rm -rvdf $myfirstfile

scp /backup/mysqldump/$myfile backup@$standby:/backup/mysqldump/
rsync -avzE –progress /backup/mysqldump/$myfile backup@X.X.X.X:/backup/autobackup/mysqldump/
#############################################################################
# To decrypt Tesing_Backup.bzip2 file
#
# openssl  aes-256-cbc  -d  -pass pass:ABCabc123@  -in  Testing_Backup.tar.gz.enc  -out  Testing_Backup.tar.gz
#############################################################################
# -d –decompress
# -c –create
# -f –force
# -v –verbose
# -z –gzip
# Password = ABCabc123@
#############################################################################

March 3, 2013 - Posted by | Security, Shell Script | ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: