Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member davetanguay's Avatar
    Join Date
    Mar 2008
    Posts
    17

    Default SOLVED: Local & Remote Backups

    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 by davetanguay; 01-24-2010 at 04:52 PM.

  2. #2
    Member
    Join Date
    Jun 2003
    Location
    Bharat
    Posts
    230

    Default

    You can easily do that using rSync in a single line code, also which you can put in a file /scripts/postcpbackup and this will run every time after cpbackup.

    Have a look
    http://www.gaztronics.net/rsync.php
    http://www.brentnorris.net/rsyncntdoc.html
    Last edited by Vinayak; 02-03-2010 at 01:32 PM. Reason: Inserted relevant links.
    Vinayak Sharma
    Vinsar.Net - Quality WebHosting Services at Economical Price USA & UK Servers
    Book Your Domain with Confidence Reliable Domain Reseller Account

  3. #3
    Member
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    174

    Default

    Excellent script!
    Last edited by krisdv; 05-11-2010 at 03:14 PM.

Similar Threads & Tags
Similar threads

  1. Simultaneous Local and Remote Backups
    By cPanelDavidG in forum Feature Requests for cPanel/WHM
    Replies: 10
    Last Post: 12-09-2011, 08:20 PM
  2. Incramental Local & Full Remote Backup Plan
    By davetanguay in forum Data Protection
    Replies: 7
    Last Post: 11-26-2009, 10:56 AM
  3. Enable both remote and local backups?
    By jhyland87 in forum Data Protection
    Replies: 9
    Last Post: 06-29-2009, 05:15 PM
  4. Parking domains with remote & local DNS
    By JIKOmetrix in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 10-29-2007, 11:40 AM
  5. Remote MySQL server (solved).
    By ERick_PL in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 08-29-2006, 06:48 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube