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!

Where is Backup Users List Located?

Discussion in 'Data Protection' started by Khalid Nihaya, Jun 25, 2018.

Tags:
  1. Khalid Nihaya

    Khalid Nihaya Registered

    Joined:
    Jun 22, 2018
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pakistan
    cPanel Access Level:
    Root Administrator
    Hi CP Community,

    I'm trying to locate the file that contains list of users that are eligible for scheduled backup, when an Admin enables backups & select a number of users for the backups from WHM.
    Can someone tell me the path of that file?
    Actually I want to create a script that would insert into that file, the users that fulfill my criteria of backup, & then the backup would run for those specific users.

    In short, please help me locate the file that contains the list of users that backup command uses for backup.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,889
    Likes Received:
    1,814
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @Khalid Nihaya,

    The backup selection value is stored in the individual cPanel user files in the /var/cpanel/users/ directory. Here's an example of a command you can use to see the status for all accounts:

    Code:
    grep BACKUP= /var/cpanel/users/*
    The modifyacct WHM API 1 function is available if you'd like to enable or disable backups for a specific user:

    WHM API 1 Functions - modifyacct - Developer Documentation - cPanel Documentation

    For example, to disable backups for a user, you'd use a command like this:

    Code:
    whmapi1 modifyacct user=myuser BACKUP=0
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Khalid Nihaya

    Khalid Nihaya Registered

    Joined:
    Jun 22, 2018
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pakistan
    cPanel Access Level:
    Root Administrator
    Ok I'm trying to use your suggested commands in a script. The logic goes like this,

    1. Fetch All Accounts From /home
    2. Fetch the accounts whose home dirs are less than 1 GB
    3. Disable BackUP For "All Users" for start.
    4. Enable BackUp For "Account with home data < 1GB... excluding suspended Accounts"
    5. Generate BackUP


    BUT I'm stuck at step 3 & 4. The reason is when I use following command twice, it either enables backup for all, or disable for all

    whmapi1 modifyacct user=$i BACKUP=[0/1]
    whereas
    [0/1] symbolizes enabling or disabling.

    Can you guys let me know what could be the reason?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,889
    Likes Received:
    1,814
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @Khalid Nihaya,

    Can you provide a full example of the code you are using in your custom script so we can attempt to reproduce the same behavior?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Khalid Nihaya

    Khalid Nihaya Registered

    Joined:
    Jun 22, 2018
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pakistan
    cPanel Access Level:
    Root Administrator
    yes here's all the code, and description of what code should accomplish.


    ### BASH SCRIPT ###

    #!/bin/bash



    ## Arrays ##

    -- I defined these arrays to sort all hosting accounts into two arrayed lists.


    -- Arrayed List 1: All accounts whose data has exceeded 1 GB data mark. Belows is command that does the trick

    L=($( comm -23 <(du -h --max-depth=1 /home 2>/dev/null | grep G | awk -F"/" '{print $NF}' | sort | egrep -vw '(home|virtfs)') <(ls -al /var/cpanel/suspended/ | grep -v 'lock' | sort) ))



    -- Arrayed List 2: All account whose data is less than 1 GB. Below command does the trick

    S=($(comm -23 <(du -h --max-depth=1 /home 2>/dev/null | egrep -v '(!G|.cp|cP|clamav)' | awk -F"/" '{print $NF}' | sort | egrep -vw '(home|virtfs)') <(ls -al /var/cpanel/suspended/ | grep -v 'lock' | sort) ))


    -- Now next step is to disable backup for all accounts to achieve zero state, so that I can set which accounts to backup next.

    -- Disable > 1GB Accounts && Disable Accounts < 1GB

    whmapi1 modifyacct user=${L[@]} BACKUP=0 && whmapi1 modifyacct user=${S[@]} BACKUP=0


    -- Enable Backup For Small Accounts.


    whmapi1 modifyacct user=${S[@]} BACKUP=1



    -- Run Backup Command.

    ## /usr/local/cpanel/bin/backup --force ##





    ### Problem In Script ###

    But when following command runs, it doesn't disable backup for all accounts. I don't know why.

    whmapi1 modifyacct user=${L[@]} BACKUP=0 && whmapi1 modifyacct user=${S[@]} BACKUP=0

    even if it may, when next command runs & enables backup, it doesn't anable backup for desired accounts.


    You can check & troubleshoot according to my logic..
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,889
    Likes Received:
    1,814
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @Khalid Nihaya,

    It looks like it's more of an issue with your specific coding, as it works successfully when manually entering the values in the WHM API 1 command. You may want to seek out feedback on a website related to programming (e.g. StackOverflow) or consult with a qualified system administrator for help with the programming itself:

    System Administration Services | cPanel Forums

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

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