We would like to split the data files into a data folder and the log files into a log folder.
if this is the default location for data files and log files, can we change it?
opt/tableau/tableau_server/data/tabsvc/logs
./opt/tableau/tableau_server/data
@Laura Cichanowicz​
Sadly, there is not a command or configuration key to change the log files location, but maybe, just maybe (last resource) if you create a support case (customer.tableau.com), Tableau support may be able to give you one instruction (if exists, but I don't think there is one).
As a workaround you may work with creating a script that creates a ziplog and copies them to the desired path, and then schedule it with crontab.
⌗VARIABLES SECTION
# Set some variables - you should change these to match your own environment
# Grab the current date in YYYY-MM-DD format
DATE=`date +%Y-%m-%d`
# Grab the current datetime for timestamping the log entries
TIMESTAMP=`date '+%Y-%m-%d %H:%M:%S'`
# Do you want to copy your archived logs to another location after completion?
copy_logs="yes"
# Where do you want to save your archived logs?
external_log_path="/Backup-Server/log-archives"
# How many days to you want to keep archived log files for in Tableau Server default path?
log_days="1"
# How many days to you want to keep archived log files for in External path?
external_log_days="3"
# What do you want to name your logs file? (will automatically append current date to this filename)
log_name="logs"
# END OF VARIABLES SECTION
# LOAD ENVIRONMENT & USER INPUT
# Load the Tableau Server environment variables into the cron environment
source /etc/profile.d/tableau_server.sh
# In case that doesn't work then this might do it
load_environment_file() {
if [[ -f /etc/opt/tableau/tableau_server/environment.bash ]]; then
source /etc/opt/tableau/tableau_server/environment.bash
env_file_exists=1
fi
}
if [ "$#" -eq 2 ] ; then
# Get tsm username from command line input
tsmuser="$1"
# Get tsm password from command line input
tsmpassword="$2"
tsmparams="-u $tsmuser -p $tsmpassword"
elif [ $(echo $TABLEAU_SERVER_DATA_DIR_VERSION | cut -d. -f1) -ge 20192 ] && (id -nG | grep -q tsmadmin || [ ${EUID} -eq 0 ]) ; then
# 2019.2 workflow. If running as tsmadmin member or root, do not set userinfo
declare tsmparams
fi
# LOGS SECTION
# get the path to the log archive folder
log_path=$(tsm configuration get -k basefilepath.log_archive $tsmparams)
echo $TIMESTAMP "The path for storing log archives is $log_path"
# count the number of log files eligible for deletion in the Tableau Server default directory and output
echo $TIMESTAMP "Cleaning up old log files..."
lines=$(find $log_path -type f -name '*.zip' -mmin +$(($log_days * 60 * 24)) | wc -l)
if [ $lines -eq 0 ]; then
echo $TIMESTAMP $lines found, skipping...
else echo $TIMESTAMP $lines found, deleting...
⌗remove log archives older than the specified number of days
find $log_path -type f -name '*.zip' -mmin +$(($log_days * 60 * 24)) -exec rm {} \;
echo $TIMESTAMP "Cleaning up completed."
fi
#archive current logs and copy to the remote storage
echo $TIMESTAMP "Archiving current logs..."
tsm maintenance ziplogs -a -t -o -f logs-$DATE.zip $tsmparams
#copy logs to different location (optional)
if [ "$copy_logs" == "yes" ];
then
echo $TIMESTAMP "Copying logs to remote share"
cp -n $log_path/* $external_log_path/
fi
⌗remove log archive older than the specified number of days in external storage
lines=$(find $external_log_path -type f -name '*.zip' -mmin +$(($external_log_days * 60 * 24)) | wc -l)
if [ "$copy_logs" == "yes" ];
then
echo $TIMESTAMP "Deleting logs older than specified number in days in remote share"
if [ $lines -eq 0 ]; then
echo $TIMESTAMP $lines found, skipping...
else echo $TIMESTAMP $lines found, deleting...
⌗remove log archives older in external storage than the specified number of days
find $external_log_path -type f -name '*.zip' -mmin +$(($external_log_days * 60 * 24)) -exec rm {} \;
echo $TIMESTAMP "Cleaning up completed."
fi
fi
# END OF LOGS SECTION
Let's suppose you store this script with name tableau-server-housekeeping-linux.bash and you stored it in /home/dmartinez, then you can test it (In this case, the user in the server with tsm rights is dmartinez) (don't forget to give executing permission to the file)
sudo su -l dmartinez -c /home/dmartinez/tableau-server-housekeeping-linux.bash
Finally, if everything is working, schedule with crontab:
sudo su -l dmartinez -c "crontab -e"
And add a line at the end. For example, to schedule it to run once a day at 01:00, add this to your crontab:
0 1 * * * /home/dmartinez/tableau-server-housekeeping-linux.bash > /home/dmartinez/tableau-server-housekeeping.log
Regards,
Diego