Last active
December 16, 2015 12:38
-
-
Save karlbaillie/5435598 to your computer and use it in GitHub Desktop.
Batch Restore cPanel Account Backups
This file contains hidden or 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/bash | |
if [ "$1" = "" ] | |
then | |
echo "No owner specified." | |
echo "Usage: $0 owner" | |
exit | |
fi | |
owner="$1" | |
grep ": $owner\$" /etc/userdomains || { | |
echo "$owner doesn't exist on this server." | |
exit | |
} | |
for file in backup* | |
do | |
username=$(echo $file | sed 's/backup.*_([a-z,A-Z,0-9]*)\./\1/') | |
grep ": $username\$" /etc/userdomains && echo "$username already exists. Skipping." || { | |
echo Restoring $username | |
/scripts/restorepkg $pwd/$file | |
/scripts/modcpuser $username --key OWNER --value=$owner | |
} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment