Created
June 24, 2013 12:55
-
-
Save osrecio/5849834 to your computer and use it in GitHub Desktop.
Get Backup Cpanel ( Files & DB's )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOG="/path_to_save_logs" | |
echo "Start backup web `date`" >> $LOG | |
cd /folder_to_save | |
FECHAF=`date +%Y.%m.%d` | |
mkdir $FECHAF | |
cd $FECHAF | |
FECHA=`date +%-m-%-d-%Y` | |
####################### | |
# Backup Web Cpanel # | |
####################### | |
DOMAIN="domain_dot_org" | |
mkdir $DOMAIN | |
cd $DOMAIN | |
USER="user_login" | |
PASS="pass" | |
REDIRECT=`curl -f -o /dev/null -w "%{redirect_url}" --insecure -c cookies.txt -d "user=${USER}&pass=${PASS}" -ssl https://${DOMAIN}:2083/login/` | |
CPSESS=`echo ${REDIRECT} | sed 's/.*\(cpsess[0-9]*\).*/\1/'` | |
if [ "$?" -gt "0" ]; then | |
echo "FAILED logging into $DOMAIN" >> $LOG; | |
else | |
echo "Logged into $DOMAIN, downloading backups" >> $LOG; | |
fi | |
# #Download databases | |
DBarray=( bd1 bd2 bd3 ) | |
for element in $(seq 0 $((${#DBarray[@]} - 1))) | |
do | |
curl -f -O -b cookies.txt --insecure -ssl https://${DOMAIN}:2083/${CPSESS}/getsqlbackup/${DBarrayLIB[$element]}.sql.gz | |
if [ "$?" -gt "0" ]; then | |
echo "FAILED downloading database: ${DBarray[$element]}" >> $LOG; | |
else | |
echo "SUCCESS downloading database: ${DBarray[$element]}" >> $LOG; | |
fi | |
done | |
# #Download backup | |
curl -f -O -b cookies.txt --insecure -ssl https://${DOMAIN}:2083/${CPSESS}/getbackup/backup-${DOMAIN}-${FECHA}.tar.gz | |
if [ "$?" -gt "0" ]; then | |
echo "FAILED downloading files ${DOMAIN}" >> $LOG; | |
exit 3; | |
else | |
echo "SUCCESS downloading files ${DOMAIN}" >> $LOG; | |
fi | |
# # Cleanup | |
rm -f cookies.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment