Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED: Local & Remote Backups

Discussion in 'Data Protection' started by davetanguay, Nov 25, 2009.

  1. davetanguay

    davetanguay Active Member

    Joined:
    Mar 30, 2008
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    51
    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
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #1 davetanguay, Nov 25, 2009
    Last edited: Jan 24, 2010
  2. Vinayak

    Vinayak Well-Known Member

    Joined:
    Jun 27, 2003
    Messages:
    274
    Likes Received:
    2
    Trophy Points:
    168
    Location:
    Bharat
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #2 Vinayak, Feb 3, 2010
    Last edited: Feb 3, 2010
  3. krisdv

    krisdv Well-Known Member

    Joined:
    Jun 18, 2003
    Messages:
    175
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Belgium
    Excellent script!
     
    #3 krisdv, Apr 14, 2010
    Last edited: May 11, 2010
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice