Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Exclude User from backups

Discussion in 'General Discussion' started by asmithjr, May 13, 2004.

  1. asmithjr

    asmithjr Well-Known Member

    Jun 13, 2003
    Likes Received:
    Trophy Points:
    I did not find anything to allow me to exclude a user or users from the backups when using cpbackup so I made a couple modifications:

    1st. I create a file called nobackup that contains the users I do not want to backup. One per line.

    2nd. I created a script (I named mvuser): This script will take the users in my nobackup file, move them out of the /var/cpanel/users directory. This way when cpbackup runs it will not backup those users since it uses the users from the /var/cpanel/users directory.

    3rd. This is the way I implemented it. I modified the cpbackup script but you could simple execute the mvuser script before and after the backups are completed.

    # mvuser - script to move users from /var/cpanel/users during backup
    # process. We move uses out of directory we do not want to backup
    # Script takes 1 argument. Either in or out.
    # Place the following two lines below the following line /scripts/cpbackup
    # close to line 280. Remember to remove the comment on the system line
    # sub backupaccts {
    # Move the users in nobackup back to users directory. See mvuser
    # system("mvuser out");
    # And the following two lines before the closing "}" for the sub backupaccts
    # close to line 346. Remember to remove the comment on the system line
    # Move the users in nobackup back to users directory. See mvuser
    # system("mvuser in");
    USERS=nobackup     # list of users not to backup
    case $1 in
            out) # move the user file out temporarily
                    for i in `cat $USERS`
                            mv $DIR/$i $TMPDIR
                            echo "mv $DIR/$i $TMPDIR"
            in) # move the user file back to DIR
                    for i in `cat $USERS`
                            mv $TMPDIR/$i $DIR
                            chmod 644 $DIR/$i
                            chown cpanel:root $DIR/$i
            *) echo "Usage: mvuser [in/out] ";;
    # End
    Note: the mvuser script takes argument in and out. Out to move the users from the /var/cpanel/users and in to move them back in. So I simply have the cpbackup script execute mvuser out before I start the backup of the users and mvuser in when the backups are complete.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice