Last active
February 23, 2019 14:03
-
-
Save Farshid928/ba27236c91b878de86f1d2318732e390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Linux shell script to backup cpanel suspended accounts which reason of suspension is mentioned "Overdue on Payment" | |
# get suspended accounts list | |
whmapi1 listsuspended > list.txt | |
# delete the first three lines to split file | |
sed -i '1d;2d;3d' list.txt | |
# evry 7 line is for 1 account. for each account will create a new file | |
split -l 7 list.txt | |
# delete the main file of suspended accounts list | |
rm list.txt | |
# this loop will affect on splited files | |
for filename in xa*; | |
do | |
# get the files contain "Overdue on Payment" phrase | |
if grep -q "Overdue on Payment" "$filename"; then | |
# get the username of accounts | |
USER="$(awk '/user/{print $NF}' "$filename")" | |
# backup selected users | |
/scripts/pkgacct $USER | |
# move backup(s) to current location. you can replace dot with your intended directory | |
mv /home/cpmove-$USER.tar.gz . | |
# end if | |
fi | |
# end for | |
done | |
#delete splited files | |
rm xa* | |
#created by github.com/Farshid928 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment