SOLVED: Local & Remote Backups

davetanguay

Active Member
Mar 30, 2008
38
1
58
After months of testing a local and remote backup solution we have finally found one that works and doesn't overload our servers.

We cannot do full cPanel backups on the server since it causes a high load on large sites (over 4gig) and causes the servers to crash for hours on end.

So we do local incremental backups (running as nice -n19) to a secondary drive using the standard cpbackup feature within WHM.

Then weekly we transfer the /backup/cpbackup/daily backup to a remote FTP server using the script below. The backup script compresses each user's backup folder to a tar.gz file before transfer. We run the script as nice -19 as follows:

nice -n19 /root/cpbackup-ncftp.sh

You must have ncftp installed to your server in order for this to work.

It's a cost effective solution since our remote FTP server is just a Windows XP machine running Filezilla. It has an external disk array of 4 SATA II drives which is very easy and inexpensive to upgrade. We're able to backup 6 cPanel servers remotely in just over a day. Total remote backup is over 600gig.

Hope this helps someone out there! I know I can sleep at night now :)

Code:
ftpUser="insert-ftp-user-here"
ftpPass="insert-password-here"
ftpHost="insert-remote-ftp-hostname-here"
remLoc="insert-server-name-here"
SUBJECT="Remote Backup of $(hostname) Completed"
TEMPFILE="$(mktemp)"
DATE="date + Y- m- d"
EMAIL="insert-email-here"

echo "cPanel Backup Script..." >> $TEMPFILE
echo "=============================" >> $TEMPFILE
echo "Backup Start Date/Time: $(date)" >> $TEMPFILE
echo "Performing Backup..." >> $TEMPFILE
cd /backup/cpbackup/
echo "Rotating & Uploading backup: $ftpHost" >> $TEMPFILE
ncftp -u $ftpUser -p $ftpPass $ftpHost -P 21 <<**
passive
cd $remLoc
rm -rf dump3
rename dump2 dump3
rename dump1 dump2
mkdir dump1
**
rm -rf /backup/*-ncftp
for i in `cat /etc/trueuserdomains | cut -d ':' -f2 | sed 's/ //'`
do
cd /backup/cpbackup/daily/
mkdir /backup/$i-ncftp
tar -zcf /backup/$i-ncftp/$i.tar.gz $i
cd /backup/$i-ncftp/
ncftp -u $ftpUser -p $ftpPass $ftpHost -P 21 <<**
passive
cd $remLoc
cd dump1
mput -R *
**
cd /backup/cpbackup/daily/
rm -rf /backup/$i-ncftp
done

echo "Backup End Date/Time: $(date)" >> $TEMPFILE
echo "=============================" >> $TEMPFILE
echo "Backup Completed " >> $TEMPFILE
echo "=============================" >> $TEMPFILE
mail -s "$SUBJECT" "$EMAIL" < $TEMPFILE
rm -f $TEMPFILE
 
Last edited:

Vinayak

Well-Known Member
Jun 27, 2003
281
4
168
Bharat
cPanel Access Level
Root Administrator
Last edited: