#!/bin/bash # Generate backups using cpbackup and then transfer them to a central server # Author: SecaGuy @ blog.secaserver.com # Local server configuration LHOSTNAME=`hostname` TEMPPATH='/root/tmp' # FTP server configuration CHOST='FTP-Server' CUSERNAME='FTP-USER' CPASSWORD='FTP-PASS' # Dont change line below FTP=`which ftp` if [ ! -d /var/cpanel/users ] then echo "cPanel users not found. Aborted!" exit 1 else eof=`ls /var/cpanel/users | egrep -v '^\..$' | egrep -v '^\...$' | wc -l` echo "$eof cPanel user(s) found in this server" [ ! -d $TEMPPATH ] && mkdir -p $TEMPPATH || : for (( i=1; i<=$eof; i++ )) do CPUSER=`ls /var/cpanel/users | egrep -v '^\..$' | egrep -v '^\...$' | head -$i | tail -1` echo "Creating backup for user $CPUSER.." /usr/local/cpanel/scripts/pkgacct $CPUSER $TEMPPATH userbackup echo "Backup done. Transferring backup to FTP server.." FILENAME=`ls $TEMPPATH | grep tar.gz` $FTP -n $CHOST <