#!/bin/bash BACKUPDIR=${1:-/backup/current} for i in $( ls $BACKUPDIR/); do if [ -d ${BACKUPDIR}/${i} ] ; then uepoch=$(stat -c %Y ${BACKUPDIR}/${i}) cepoch=$(expr $uepoch + 86400 + 86400) epoch=$(date +%s) echo "${BACKUPDIR}/${i} Epoch $epoch CEpoch $cepoch" check=$(grep -E "^${i}:" /etc/passwd) if [ -n "$check" ] ; then echo "$i found!" else if [ "$cepoch" -gt "$epoch" ] ; then pushd $BACKUPDIR mkdir -p /home/cprestore echo "tar zcpvf /home/cprestore/${i}.tar.gz --exclude=homedir/* ${i}" tar zcpvf /home/cprestore/${i}.tar.gz --exclude=homedir/* ${i} popd echo "/scripts/restorepkg /home/cprestore/${i}.tar.gz" /scripts/restorepkg /home/cprestore/${i}.tar.gz echo "rsync -avz --stats --progress ${BACKUPDIR}/${i}/homedir/ /home/${i}/" rsync -avz --stats --progress ${BACKUPDIR}/${i}/homedir/ /home/${i}/ if [ ! -f /root/fixperms.sh ] ; then wget https://raw.githubusercontent.com/PeachFlame/cPanel-fixperms/master/fixperms.sh -O /root/fixperms.sh chmod +x /root/fixperms.sh fi chown -R ${i}:${i} /home/${i} chown ${i}:mail /home/${i}/etc echo "/root/fixperms.sh -a ${i}" /root/fixperms.sh -a ${i} else echo "Skipped!" fi fi fi done