Monday, June 06, 2016

Script to backup wso2-server directory to an external server

Note : Make sure you have only the wso2-server in the backupDir.
Please pay attention to the bold parts of the script below

Fill-out the backupUser, backupServer and backupDest varibles for the remote backup server.

Improvements
1. You can omit the password promting for scp by configuring keys between your server and remote server. refer[1]
2. You can use incron job[1] to automate backing up on daily (timely) basis.
http://susinda.blogspot.com/2016/05/wso2-depsync-with-rsync-and-incron.html


backupDir=/apps/wso2
backupUser=backupRoot
backupServer=backupVM
backupDest=/apps/backups
cd $backupDir
rm *.zip

a=$(hostname)
b=`date +%Y-%m-%d`
c='.zip'
zipName=$b-$a$c
pack=$(ls)
echo zipping $pack to $zipName
zip -r $zipName $pack
echo scp..ing $zipName to $backupUser@$backupServer:$backupDest
scp $zipName $backupUser@$backupServer:$backupDest
echo Backup completed ..!