Collapse

Announcement

Collapse
No announcement yet.

Backup cPanel accounts in alphabetically order as per user input

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Backup cPanel accounts in alphabetically order as per user input

    Here is script that you can use to take backup of all you cPanel users in alphabetical order as per user input.

    The script will be useful when your server is always under load and you cant run cPanel's default backups for hours so you need to take backup in batches for users in alphabetical orders.


    Code:
    #!/bin/bash
    ##----------Created By Swapnil at 24x7servermanagement.com -----------------------------##
    ##---------- Purpose : To backup cPanel accounts in alphabetically order as per user input----------##
    ##-----NOTE: This script requires root privileges, otherwise you could run the script -------##
    
    
    D="----------------"
    S="****************"
    
    date=$(date +"%m-%d-%y")
    mkdir -p /backup/$date/
    
    bakdst="/backup/$date/"
    ad="$(cat $bakdst/adone | tr '\n' ' ')"
    
    #Backup done alphabet list
    
    echo "These accounts has been done so far :  "
    echo "$D"
    echo "$ad"
    echo "$D"
    
    #Get input from user
    
    echo -n "Enter alphabet to create backup of accounts[a-z]: "
    read alpha  #$alpha
    
    #Get users of cPanel as per above input
    
    ls -l /var/cpanel/users/[$alpha]* | grep ^- | tr -s ' ' | cut -d' ' -f9 | cut -d / -f5  > /backup/alist
    
    for i in `cat /backup/alist`; do
    
    /scripts/pkgacct $i $bakdst >> $bakdst/manualbklog.txt 2>&1
    
    echo "$D"  >> /backup/done
    echo "Backup of User $i done" >> /backup/done
    
    done
    
    #Lots of echo
    
    echo $S >> /backup/done
    echo "Alphabet Done : $i"
    echo $S >> /backup/done
    
    
    echo $i >> $bakdst/adone
    echo "$D"
    echo " Backup of up All accounts started with "A" successfully done to folder $bakdst "
    echo " Check for any errors at : $bakdst/manualbklog.txt "
    echo " ........... Successfully Done .......... "
    
    exit 0

  • #2
    Thanks Swapnil. This is really good script.

    Comment

    Working...
    X