Skip to content

Instantly share code, notes, and snippets.

@Elamurugan-Nallathambi
Last active December 22, 2020 05:13
Show Gist options
  • Select an option

  • Save Elamurugan-Nallathambi/7043becbe6f0b5eab2c3fecc2a7213bf to your computer and use it in GitHub Desktop.

Select an option

Save Elamurugan-Nallathambi/7043becbe6f0b5eab2c3fecc2a7213bf to your computer and use it in GitHub Desktop.
Copies log & report from root user level to non root user home directory
#!/bin/bash
#get latest raw version of https://gist.github.com/Elamurugan-Nallathambi/7043becbe6f0b5eab2c3fecc2a7213bf
#curl -s https://gist.githubusercontent.com/Elamurugan-Nallathambi/7043becbe6f0b5eab2c3fecc2a7213bf/raw/ca1b901b8ca98a88b4f09649231765441c599016/sync_log_report_files.sh | bash -s -- /var/www/html/vusevapor.com/htdocs
domain_home=${1:-none}
if [ "$domain_home" = "none" ]; then
exit 1
fi
log_home_dir="/home/centos/logs_n_reports/"
today=$(date '+%Y_%m_%d')
log_dir="${log_home_dir}${today}"
mkdir -p "${log_dir}/log"
mkdir -p "${log_dir}/report"
sudo su - <<EOF
echo "The following files being Synced to ${log_dir} from ${domain_home}"
ls -ll "${domain_home}/var/log"
cp -a "${domain_home}/var/log/." $log_dir/log/
#ls -ll "${domain_home}/var/report"
cp -a "${domain_home}/var/report/." $log_dir/report/
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment