Server Mac 229

Mac229

OS: Mac OS X Tiger (10.5.4)

Services:

Trac SVN: TuProlog, TupleCentre, PJ, Respect, Tucson, Soda, stochmachine

IP: 137.204.107.229

Disks: /   (232 GB)

SVN and Trac repository Backup script 

Script name: trac-svn-fullbackup.sh The script is located in the directory /Users/Shared/

This script is scheduled to run daily at 05.00 am. (see the file /etc/crontab)

trac-svn-fullbackup.sh

#!/bin/bash

# usage  sudo /Users/Shared/trac-svn-fullbackup.sh         

PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.3/bin/
PATH=$PATH:/usr/local/bin/

data=`date +%Y-%m-%d-%H%M`
bkp_path=/Users/Shared/backup/$data-backup
bkp_logfile=/Users/Shared/backup/$data-backup.log
tarfile=/Users/Shared/backup/backup$data.tar.gz


echo Path is: $PATH 2>&1>>$bkp_logfile

echo create $bkp_path and Backup in it 2>&1>>$bkp_logfile
mkdir $bkp_path

echo  2>&1>>$bkp_logfile
echo SVN Backup di: pj  2>&1>>$bkp_logfile
echo 2>&1>>$bkp_logfile
/usr/local/bin/svnadmin dump /trac-svn/svn/pj/  >$bkp_path/pj.svn.bkp 2>>$bkp_logfile
cp /trac-svn/svn/pj/conf/authz.conf $bkp_path/pj.authz.conf 2>&1>>$bkp_logfile
trac-admin /trac-svn/trac/pj/ hotcopy $bkp_path/pj.trac.bkp 2>&1>>$bkp_logfile



echo 2>&1>>$bkp_logfile
echo SVN Backup di: respect  2>&1>>$bkp_logfile
echo 2>&1>>$bkp_logfile
/usr/local/bin/svnadmin dump /trac-svn/svn/respect/  >$bkp_path/respect.svn.bkp 2>>$bkp_logfile
cp /trac-svn/svn/respect/conf/authz.conf $bkp_path/respect.authz.conf 2>&1>>$bkp_logfile
trac-admin /trac-svn/trac/respect/ hotcopy $bkp_path/respect.trac.bkp 2>&1>>$bkp_logfile


#
echo 2>&1>>$bkp_logfile
echo SVN Backup di: tucson  2>&1>>$bkp_logfile
echo 2>&1>>$bkp_logfile
#
/usr/local/bin/svnadmin dump /trac-svn/svn/tucson/  >$bkp_path/tucson.svn.bkp 2>>$bkp_logfile
cp /trac-svn/svn/tucson/conf/authz.conf $bkp_path/tucson.authz.conf 2>&1>>$bkp_logfile
trac-admin /trac-svn/trac/tucson/ hotcopy $bkp_path/tucson.trac.bkp 2>&1>>$bkp_logfile
#
echo 2>&1>>$bkp_logfile
echo SVN Backup di: tuplecentre  2>&1>>$bkp_logfile
echo 2>&1>>$bkp_logfile
#
/usr/local/bin/svnadmin dump /trac-svn/svn/tuplecentre/  >$bkp_path/tuplecentre.svn.bkp 2>>$bkp_logfile
trac-admin /trac-svn/trac/tuplecentre/ hotcopy $bkp_path/tuplecentre.trac.bkp 2>&1>>$bkp_logfile


#
echo 2>&1>>$bkp_logfile
echo SVN Backup di: tuprolog  2>&1>>$bkp_logfile
echo  2>&1>>$bkp_logfile
#
/usr/local/bin/svnadmin dump /trac-svn/svn/tuprolog/  >$bkp_path/tuprolog.svn.bkp 2>>$bkp_logfile
cp /trac-svn/svn/tuprolog/conf/authz.conf $bkp_path/tuprolog.authz.conf 2>&1>>$bkp_logfile
trac-admin /trac-svn/trac/tuprolog/ hotcopy $bkp_path/tuprolog.trac.bkp 2>&1>>$bkp_logfile

#
echo 2>&1>>$bkp_logfile
echo SVN Backup di: stochmachine  2>&1>>$bkp_logfile
echo  2>&1>>$bkp_logfile
#
/usr/local/bin/svnadmin dump /trac-svn/svn/stochmachine/  >$bkp_path/stochmachine.svn.bkp 2>>$bkp_logfile

# non esiste directory trac per stochmachine
#trac-admin /trac-svn/trac/stochmachine/ hotcopy $bkp_path/stochmachine.trac.bkp 2>&1>>$bkp_logfile
cp /trac-svn/svn/stochmachine/conf/authz.conf $bkp_path/stochmachine.authz.conf 2>&1>>$bkp_logfile


#---------------------------------------------------------
# compressione della directory
#---------------------------------------------------------

echo 2>&1>>$bkp_logfile
echo zip $bkp_path  2>&1>>$bkp_logfile
tar -cvvzf $tarfile $bkp_path/ 2>&1>>$bkp_logfile


#---------------------------------------------------------
#codice aggiunto per trasferire i files di bkp su server win6
#---------------------------------------------------------
tmp_sftpfile='/Users/Shared/backup/tmpfile'
sftp_target='backup@137.204.107.6:/cygdrive/d/backup/mac229/'
tarfolder=/Users/Shared/backup/tar/


echo creating sftp file 2>&1>>$bkp_logfile
touch $tmp_sftpfile 2>&1>>$bkp_logfile
echo "put $tarfile
ls 
$tarfile
quit"
> $tmp_sftpfile
cat $tmp_sftpfile >> $bkp_logfile

echo sending file $tarfile 2>&1>>$bkp_logfile
sftp -b $tmp_sftpfile $sftp_target 2>&1>>$bkp_logfile
rm $tmp_sftpfile 2>&1>>$bkp_logfile