I have a few questions regarding rsync as a backup method. When I used the script example it backed up up my entire /home/openkm/ folder. Not sure that is what I want as that folder contains some other applications, workspaces, etc. So I have edited the rsync command to only backup the tomcat folder.
You will also note that I have commented out the mount for now. I will rsync locally until I sort out all the issues.
what is causing this behavior?
You will also note that I have commented out the mount for now. I will rsync locally until I sort out all the issues.
Code: Select all
When I opened the backup destination as defined in my config section "/home/openkm/ABTopenkm/", I expected to see the contents of the tomcat folder. Instead I saw /home/openkm/ABTopenkm/home/openkm/tomcat/#!/bin/bash
#
## BEGIN CONFIG ##
HOST=$(uname -n)
DATABASE_PASS="*secret*"
OPENKM_DB="okmdb"
OPENKM_HOME="/home/openkm"
TOMCAT_HOME="$OPENKM_HOME/tomcat-7.0.61"
DATABASE_EXP="$OPENKM_HOME/ABTopenkm/db"
BACKUP_DIR="/home/openkm/ABTopenkm"
RSYNC_OPTS="-apzhR --stats --delete --exclude=*~ --delete-excluded"
## END CONFIG ##
# Check root user
if [ $(id -u) != 0 ]; then echo "You should run this script as root"; exit; fi
# Delete older local database backup
echo -e "### BEGIN: $(date +"%x %X") ###\n"
rm -rf $DATABASE_EXP
mkdir -p $DATABASE_EXP
# Mount disk
#if mount | grep "$BACKUP_DIR type" > /dev/null; then
# echo "$BACKUP_DIR already mounted";
#else
# mount "$BACKUP_DIR";
#
# if mount | grep "$BACKUP_DIR type" > /dev/null; then
# echo "$BACKUP_DIR mounted";
# else
# echo "$BACKUP_DIR error mounting";
# exit -1;
# fi
#fi
# Stop Tomcat
/etc/init.d/tomcat stop
# Clean logs
echo "Clean Tomcat temporal files."
rm -rf $TOMCAT_HOME/logs/*
rm -rf $TOMCAT_HOME/temp/*
rm -rf $TOMCAT_HOME/work/Catalina/localhost
# Backup database
if [ -n "$DATABASE_PASS" ]; then
echo "* Backuping MySQL data from $OPENKM_DB..."
mysqldump -h localhost -u root -p$DATABASE_PASS $OPENKM_DB > $DATABASE_EXP/mysql_$OPENKM_DB.sql
echo "-------------------------------------";
fi
# Create backup
rsync $RSYNC_OPTS $TOMCAT_HOME $BACKUP_DIR/
# Start Tomcat
/etc/init.d/tomcat start
echo -e "\n### END: $(date +"%x %X") ###"
# Umount disk
#sync
#umount "$BACKUP_DIR"
what is causing this behavior?