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.

Backup and restore account setup only

Discussion in 'Data Protection' started by mcegielka, Jan 26, 2012.

  1. mcegielka

    mcegielka Registered

    Joined:
    Jan 26, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    I'm wondering whether it's possible to have cPanel's scheduled backups archive (and allow restoration of) everything -except- 'added' files in, for example, public_html?

    We're already backing up files via Jungledisk nightly, so our backups are stored offsite and easily recoverable. However, in order to stop backing up the entire home directory of each account we have the 'Backup accounts' option set to off, and so there's no backup of accounts that can be restored when I click through to restore a Daily/Weekly/Monthly backup.

    Is using a cpbackup-exclude.conf file the best way to do this, or can it be configured through the WHM interface? Will this also include an SQL dump of all the account's databases?

    Many thanks
     
  2. hoststop

    hoststop Well-Known Member

    Joined:
    Dec 6, 2011
    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Bolton, UK
    cPanel Access Level:
    Root Administrator
    A customized script will help in performing the backups as desired. While performing the backups, use the parameter --skiphomedir which will exclude public_html directory for all accounts.
     
  3. mcegielka

    mcegielka Registered

    Joined:
    Jan 26, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Is it possible to use the --skiphomedir option in a scheduled backup? That is, backups automatically taken daily and configured via the WHM web frontend?
     
  4. hoststop

    hoststop Well-Known Member

    Joined:
    Dec 6, 2011
    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Bolton, UK
    cPanel Access Level:
    Root Administrator
    AFAIK the default cPanel backups do not have such option available. A custom script should help.
     
  5. texo

    texo Well-Known Member

    Joined:
    Mar 28, 2007
    Messages:
    143
    Likes Received:
    0
    Trophy Points:
    16
    Here is a rough script which you can modify to serve your needs. I adapted it from someone else, can't remember who.

    Create a file at /home/counterfile with this content:

    Code:
    day=0
    and then create this script as /usr/local/backup.sh

    Code:
    #!/bin/bash
    
    (. /home/counterfile
    day=$(( $day + 1 ))
    if [ $day == 8 ]
    then day=1
    fi
    echo "day=$day" > /home/counterfile
    . /home/counterfile
    
    logfile=/home/backup_day"$day".log
    (if [ -e "$logfile" ]; then
      rm -f "$logfile"
    fi)
    echo `date '+%D %T'` "Initiating backup to backup day"$day"" >> "$logfile"
    
    /usr/bin/find /var/cpanel/users -type f -printf "%f\n" |
    while read user; do
    rm -f /home/*gz
    /scripts/pkgacct --skiphomedir --split "$user"  >> $logfile
    
    
    scp /home/cpmove-"$user".tar.gz root@backupserver:/path/backed-up-server-name/cpmove-"$user".tar.gz >> $logfile 2>&1
    (if [ $? -eq 0 ]; then
      echo `date '+%D %T'` "Uploaded cpmove-"$user".tar.gz to backup server" >> $logfile
      else exit $?
    fi)
    
    done
    
    rm -f /home/*gz
    echo `date '+%D %T'` "Backup completed." >> $logfile
    mail -s "ServerName Log of backup Backup for day"$day"" your@email.address < $logfile
    )
    
    If you run it every day via cronjob:

    Code:
    0 2 * * * sh /usr/local/backup.sh
    
    then you will have backups of each account's config, excluding public_html for each of the past 7 days.

    You can then run an rsync of the public_html directories once a week or whatever.
     
Loading...

Share This Page