Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Feb 2010
    Location
    Planet Earth
    Posts
    5

    Default Modifying cpbackup script to skip home dir

    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. #2
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Dec 2004
    Posts
    392

    Wink 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 \;
    UK Managed Hosting
    UK Linux Support
    The information given above is intended to be advice only.

  3. #3
    Member
    Join Date
    Feb 2010
    Location
    Planet Earth
    Posts
    5

    Default

    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. #4
    cPanel Product Evangelist Infopro's Avatar
    Join Date
    May 2003
    Location
    Pennsylvania
    Posts
    7,165
    cPanel/Enkompass Access Level

    Root Administrator

    Lightbulb

    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. #5
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Sep 2006
    Location
    Virginia Beach, VA
    Posts
    254
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #6
    Member
    Join Date
    Dec 2009
    Posts
    12

    Default

    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.
    Last edited by morteza; 04-16-2010 at 04:12 PM.

Similar Threads & Tags
Similar threads

  1. Modifying cpbackup script to skip home dir
    By Poopool in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 02-10-2010, 05:30 PM
  2. users in dir other than /home
    By mgdoyle in forum cPanel and WHM Discussions
    Replies: 21
    Last Post: 08-11-2005, 09:16 AM
  3. pure-ftp home dir
    By lbccserv in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 08-04-2005, 10:47 AM
  4. cpbackup does NOT backup Mysql Dir!?
    By Jedia in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 01-05-2005, 08:30 PM
  5. Custom home dir... etc
    By vogue in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 03-20-2004, 05:44 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube