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.

Modifying cpbackup script to skip home dir

Discussion in 'Data Protection' started by Poopool, Feb 9, 2010.

  1. Poopool

    Poopool Member

    Joined:
    Feb 9, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Planet Earth
    Hi,

    I'm going to make it short, I really appreciate some assistance.
    Here is the scenario :
    Let's say few hundred accounts are hosted on one server, backups are generating every week using /scripts/cpbackup for less than 2G accounts. Big accounts are excluding using /etc/cpbackup-userskip.conf
    now here is the question:
    is it possible to configure or modify /scripts/cpbackup to generate backup for those accounts that are over 2G but with --skiphomedir option?
    As you know if you run
    /scripts/pkgacct --skiphomedir user
    it generates backup but skips /home/user which is ideal for big accounts as you can restore backup on another server and copy homedir using rsync.
    I have the list of big accounts so that's not the problem, the only problem is to run /scripts/cpbackup with --skiphomedir for specific users in order to prevent overloading.

    thanks for your help
     
  2. forlinuxsupport

    forlinuxsupport Well-Known Member
    PartnerNOC

    Joined:
    Dec 22, 2004
    Messages:
    386
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Solution

    There are a couple of options.

    1) You could exclude that user from the normal cpbackup and instead create cron job to do :
    /scripts/pkgacct --skiphomedir user

    2) Create skip-dir files in the BIG directories :
    e.g. find /home/ -iname public_html -type d -exec touch {}/.cpbackup-skip \;
     
  3. Poopool

    Poopool Member

    Joined:
    Feb 9, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Planet Earth
    Thank you for your help, really appreciate it. Actually I prefer to use cpbackup script instead of writing a one myself as I need to ftp backup files to our backup server and cpbackup is already configured to do that.
    If I can make a another version of cpbackup that uses pkgacct with --skiphomedir so I can use that for bigger accounts and the original one for smaller accounts that would be awesome.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,452
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You know, a nice idea for a Feature Request might be to have an option added to the Select Users screen in the Backup Configuration area where you could tick a checkbox for those large accounts you might want to have the homedir skipped. Or even the Edit account page if there was an extra option that could be turned on or off per account to skip the homedir that the backup script would see and react to appropriately.


    Just thinking out loud here...
     
  5. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    817
    Likes Received:
    22
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    Edit /etc/cpbackup-exclude.conf and list the files/folder you don't want backed up.

    On a per-account basis, you can edit the cpbackup-exclude.conf in the user's home folder to exclude files/folders for just that user.
     
  6. morteza

    morteza Member

    Joined:
    Dec 8, 2009
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Here is what we did for similar problem; we put a simple script let's say /scripts/backup-large-accounts.sh which makes a backup from large accounts without their home directory, with below contents:

    Code:
    #!/bin/sh
    cat /etc/cpbackup-userskip.conf | while read f
    do
        file=cpmove-$f.tar.gz
        /scripts/pkgacct --skiphomedir "$f" > temp.txt
        sleep 30
        dir="/"`cat temp.txt |grep "pkgacctfile is"|awk -F "/" '{print $2}'`
        host=backup-ftp-server-name-or-ip
        pass=ftppass
        user=ftpuser
        /usr/bin/ftp -in <<EOF
        open $host
        user $user $pass
        bin
        lcd $dir
        mput $file
        quit
        EOF
    EOF
        cd $dir
        rm -f $file
    done
    In case you wanna modify it, the above code takes username of big accounts from /etc/cpbackup-userskip.conf , makes a backup from the user without home directory, then finds out which home directory the backup file is stored (as you know it's one of home drives with most available disk space), after a 30 second delay, connects to the backup server through FTP, uploads the backup file cpmove-username.tar.gz there, removes it from your server, and goes to next user. You need to enter ftp server name and login info.

    To do it weekly, add a cron job like:
    0 3 * * 0 /scripts/backup-large-accounts.sh 2>&1


    Needless to say, /scripts/backup-large-accounts.sh should have 755 permission. It works on dozens of servers as I tested and no problems, no overloads etc. Hope this helps.
     
    #6 morteza, Apr 16, 2010
    Last edited: Apr 16, 2010
Loading...

Share This Page