#!/bin/bash # +----+----+----+----+ # | | | | | # Author: Mark David Scott Cunningham | M | D | S | C | # +----+----+----+----+ # Created: 2015-08-17 # Updated: 2015-08-17 # # Purpose: Restore borked sites from account backups; remove account before restore # Help output if requested or not enough parameters provided if [[ -z $2 || $@ =~ -h ]]; then echo " Usage: $0 [ ...] .. Directory where .tar.gz files are .... cPanel account names to restore " elif [[ -n $1 && -n $2 ]]; then # Set directory to look for backups in SRC_DIR=$1; shift # Loop though list of accounts for ACCT in $@; do BACKUP="$ACCT.tar.gz" if [[ -f ${SRC_DIR}/$BACKUP ]]; then echo "Heading home .." cd /home/ echo "$ACCT :: Copying $BACKUP to /home/ .." cp ${SRC_DIR}/$BACKUP ./ echo "$ACCT :: Removing afflicted .." /scripts/removeacct $ACCT --keepdns --force echo "$ACCT :: Restoring .." /scripts/restorepkg $BACKUP echo "$ACCT :: Cleanup .." rm /home/$BACKUP else echo "$ACCT :: ${SRC_DIR}/$BACKUP not found!" fi done fi