Create files /root/bkp.sh and /root/cred
chmod 755 /root/bkp.sh
----------------------------------------------------------------------------------------------
vi /root/bkp.sh
#!/bin/bash
DATE=`date +Date%d-%H%M%S`
TOIP=`tail -1 cred | awk '{ print $4 }'`
PORT=`tail -1 cred | awk '{ print $3 }'`
for i in `sed -n '/---START---/,/---ENDOF---/p' cred | grep -v ^-- | awk '{ print $2 }'`
do
DOMAIN=$i
/scripts/pkgacct "$DOMAIN"
scp -P $PORT /home/cpmove-"$DOMAIN".tar.gz root@"$TOIP":/<backup-path>/"$DATE"_cpmove-"$DOMAIN".tar.gz
rm -rf /home/cpmove-"$DOMAIN".tar.gz
done
----------------------------------------------------------------------------------------------
List the domains in file /root/cred for which you wish to take the backup.
vi /root/cred
---START---
domain-name1: cpanel-user-name1
domain-name2: cpanel-user-name2
---ENDOF---
remote-server-hostname remote-server-IP SSH-PORT remote-server-IP
----------------------------------------------------------------------------------------------
Then run the script /root/bkp.sh to initiate the backup.
No comments:
Post a Comment