#!/bin/bash if [ ! "$(pwd | grep scripts$)" ] ; then echo "Working directory is wrong" exit 1; fi . _config.sh filesPath="$PUB_PUBLIC_HTML/$PROJECT_NAME/$BRANCHE_PATH/www/$FILES_DIRECTORY" archiveName="`echo $FILES_DIRECTORY | sed 's/\W+/_/'`.tar.bz2" if [ -d $filesPath ] ; then # check if exists backup directory if [ ! -d $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH ] ; then if [ ! "$($SVN info $REPOSITORY_URL/$PROJECT_NAME/$FILES_BACKUP_DIR 2>/dev/null | grep '^Revision:')" ] ; then mkdir -p $PROJECT_PATH/$FILES_BACKUP_DIR mkdir -p $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH $SVN add --parents $PROJECT_PATH/$FILES_BACKUP_DIR else CURRENT_DIR=`pwd` cd $PROJECT_PATH/ $SVN up --non-recursive $FILES_BACKUP_DIR cd $CURRENT_DIR if [ ! "$($SVN info $REPOSITORY_URL/$PROJECT_NAME/$FILES_BACKUP_DIR/$BRANCHE_PATH 2>/dev/null | grep '^Revision:')" ] ; then mkdir -p $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH $SVN add --parents $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH else CURRENT_DIR=`pwd` cd $PROJECT_PATH/ $SVN up $FILES_BACKUP_DIR/$BRANCHE_PATH cd $CURRENT_DIR fi fi fi ./removeThumbnails.sh cd $filesPath $TAR -cjf $archiveName * cd $BASE_PATH/scripts if [ -f $filesPath/$archiveName ] ; then mv $filesPath/$archiveName $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH if [ -n "$($SVN st $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH/$archiveName | grep ^?)" ] ; then $SVN add $PROJECT_PATH/$FILES_BACKUP_DIR/$BRANCHE_PATH/$archiveName fi #echo 'All done. Commit required'; $SVN ci $PROJECT_PATH/$FILES_BACKUP_DIR -m "Project files update. NOTASK" else echo "ERROR: Can not create backup file" exit 1 fi else echo "ERROR: Files for backup is not found" exit 1 fi exit 0