The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Suggestions for offsite Backup Scripts

Discussion in 'Data Protection' started by vicos, Jan 24, 2012.

  1. vicos

    vicos Well-Known Member

    Joined:
    Apr 18, 2003
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    Hi, I'm working on scripts to copy daily CPANEL backups off-server and offsite. Appreciate any suggestions/tweaks to the following:

    First, every thing is initiated from /scripts/postcpbackup

    Code:
    #!/bin/sh
    
    # This script is called after normal CPANEL Backups complete
    
    # First ftp all *.tar.gz files in /backup/cpbackup/daily to the FTP/NAS server we have thru our ISP.
    # Note that this server can only be accessed from the private LAN. FTP is the supported protocol.
    # Bandwidth is *not* charged to our account.
    
    /root/backups/offsitebackup.sh
    
    # Now, either on a specific Day of the Week (DOW) or day(s) of the month, execute a script to 
    # copy the same backup files to an offsite backup site we can access from the public internet.
    # This service supports rsync and we will use that instead of FTP.
    # Bandwidth usage is charged to our account.
    
    # Need logic to do DOW or DOM calculations to run this only on the required days
    
    #### /root/backups/ibackup.sh
    
    # All Finished...
    /root/backups/offsitebackup.sh

    Code:
    #!/bin/sh
    
    # This script will FTP CPANEL backups to an offsite FTP server
    # It should be called from /scripts/postcpbackup
    # See: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/ScriptHooks
    # 
    
    ############################################################
    #===> site-specific variables - customize for your site
    
    # Directory where backup files are located on this server
    backupdir=/backup/cpbackup/daily
    
    # site-specific variables for remote FTP
    
    ftpserver="nas.softlayer.com"
    ftpuser="xxxxx"
    ftppasswd="yyyyy"
    ftpdir="server08"
    
    # Be sure to manually create the ftpdir on the ftp server
    # or the script will just put them in the root if it can't cd.
    
    #===> END site-specific variables - customize for your site
    ############################################################
    
    # FTP it to the off-site server
    
    ftp -n $ftpserver <<EOF
    user $ftpuser $ftppasswd 
    bin
    prompt
    cd $ftpdir
    lcd ${backupdir}
    mput *.tar.gz
    quit
    EOF
    
    # And we're done
    echo "Offsite Backup Complete!"
    exit
    
    /root/backups/ibackup.sh not posted in this thread. There are other threads that explain how to do offserver rsync.
     

Share This Page