#!/bin/sh ############################################################################################################ # CRB ( Cpanel Rsync Backup ) Version 0.1b Author: Fernando Morgenstern # ############################################################################################################ # # # The license of this software is located at the same directory of this program. Please read the LICENSE # # before you make copies or distribute this software. # # # ############################################################################################################ # Read config file CONF="/usr/local/crb/crb.conf" if [ -f "$CONF" ] && [ ! "$CONF" == "" ]; then source $CONF else head echo "\$CONF not found." exit 1 fi # Read all usernames and start cpanel backup without backing up home files while read LINE do USERNAME=`echo $LINE | cut -d: -f2` /scripts/pkgacct --skiphomedir $USERNAME done < $USERFILES # Do rsync rsync -avz $RSYNC_OPTIONS --delete -e 'ssh -p 2200' /home/ $BSERVER_USER@$BSERVER:/$BASEDIR/backup/ # Get current date CURRENT_DATE=`date +%Y%m%d`; # Get remove date REMOVE_DATE=`date --date "$NUMBER_DAYS days ago" +%Y%m%d`; # Create a snapshot ssh -p $BSERVER_SSH_PORT $BSERVER_USER@$BSERVER "tar -c $BASEDIR/backup/ > $BASEDIR/backup$CURRENT_DATE.tar; bzip2 -z $BASEDIR/backup$CURRENT_DATE.tar;" # Remove old snapshot ssh -p $BSERVER_SSH_PORT $BSERVER_USER@$BSERVER "rm -f $BASEDIR/backup$REMOVE_DATE.tar.bz2" exit 0