Hello,
One of my clients is currently hosted on a shared server and i need to know if it is possible to create a script that will package up the entire public_html folder save it somewhere on his account and email him the link.
Rich
Printable View
Hello,
One of my clients is currently hosted on a shared server and i need to know if it is possible to create a script that will package up the entire public_html folder save it somewhere on his account and email him the link.
Rich
It is possible. You can write script to do this. :)
This could be a good start:
http://www.volunteercentergr.org/con...ire-publichtml
Good luck!
Here is what I would do (assuming a cPanel server) -
Code:for i in `ls /var/cpanel/users`;
do
tar -zcvf /home/$i/public_html/backup_of_public_html.tar.gz /home/$i/public_html
chown $i:$i /home/$i/public_html/backup_of_public_html.tar.gz
Get email address and domain name from /var/cpanel/users/$i and prepare URL and email it to him using mutt.
done
If you enable cpanel's daily backup there will be a link in his cpanel to download his last daily backup.
Whipped this up real quick, sorry for the crappy formatting (I wrote it in the WHT reply box, not good for formatting)
Code:#!/bin/bash
# Backup script version 90000
EMAIL_ADDRESS="whatever@whatever.com"
EMAIL_SUB="backup completed on $(hostname -s)"
EMAIL_FILE="/tmp/emailout.txt"
LOG_FILE="something.log"
DATA_PATH="/some/directory/"
OUTPUT_FILE="$(hostname -s)_$(date +%m%d%y).tar.gz"
# Int
COUNTER="0"
# Make sure we can access the path
if [ -d $DATA_PATH ] ; then
for files in `ls $DATA_PATH` ; do
tar -czvf $OUTPUT_FILE $DATA_PATH
let COUNTER+=1
done
if [ $? -ne "0" ] ; then
echo -e "some error" >> $LOG_FILE
fi
# Build some small email results file.
echo -e "<------------- File Size ------------->" >> $EMAIL_FILE
du -h $OUTPUT_FILE >> $EMAIL_FILE
echo -e "<------------- File Report ------------->" >> $EMAIL_FILE
echo -e "$COUNTER files have been backed up" >> $EMAIL_FILE
# send email
/bin/mail -s "$EMAIL_SUB" "$EMAIL_ADDRESS" < $EMAIL_FILE
if [ -f $EMAIL_FILE ] ; then rm -rf $EMAIL_FILE ; fi
else
echo -e "Path does not exist"
fi