Update production/download_site/backup-drupal.sh

This commit is contained in:
Ste Vaidis 2024-02-27 12:45:34 +02:00
parent 72dadb5523
commit 03f9a94a83

View File

@ -10,8 +10,8 @@ echo
# show to screen and also write to log # show to screen and also write to log
# #
function log() { function log() {
echo -e "\e[96m`date +'%d/%m/%Y %H:%M:%S'`\e[39m $1" echo -e "\e[96m`date +'%d/%m/%Y %H:%M:%S'`\e[39m ${1}"
echo -e "`date +'%d/%m/%Y %H:%M:%S'` $1" >> $LOG echo -e "`date +'%d/%m/%Y %H:%M:%S'` ${1}" >> ${LOG}
} }
# #
@ -92,22 +92,25 @@ function create_tarball() {
mv ${TARBALL} ${DOWNLOAD_PATH} mv ${TARBALL} ${DOWNLOAD_PATH}
# calculate download time and add 2 minutes for the user to click the download link # calculate download time and add 2 minutes for the user to click the download link
INTERNET_Mbps=50000000 # 50Mbps INTERNET=40000 # 5Mbps
SIZE=$( du -sh ${DOWNLOAD_PATH}/${TARBALL} | awk '{print $1}' ) SIZE=$( du -sh ./${TARBALL} | awk '{print $1}' )
SIZE_BITS=$( du -s ${DOWNLOAD_PATH}/${TARBALL} | awk '{print $1}' ) SIZE_BYTES=$( du ./${TARBALL} | awk '{print $1}' )
DOWNLOAD_SECS=$(( ${SIZE_BITS} / ${INTERNET_Mbps} )) SIZE_BITS=$(( SIZE_BYTES * 8 ))
DOWNLOAD_SECS=$(( ${SIZE_BITS} / ${INTERNET} ))
AVAILABLE_SECS=$(( ${DOWNLOAD_SECS} + 120 )) AVAILABLE_SECS=$(( ${DOWNLOAD_SECS} + 120 ))
AVAILABLE_MINS=$(( ${AVAILABLE_SECS} / 60 )) AVAILABLE_MINS=$(( ${AVAILABLE_SECS} / 60 ))
# create download link # create download link
log "" echo >> ${LOG}
log " 🍓 DOWNLOAD" log " 🍓 DOWNLOAD"
log "" echo >> ${LOG}
log "URL : https://${DOMAIN}/${TARBALL}"
log "Size : ${SIZE}" echo "URL : https://${DOMAIN}/${TARBALL} " >> ${LOG}
log "Available for : ${AVAILABLE_MINS} minutes" echo "Size : ${SIZE}" >> ${LOG}
log "" echo "Available for : ${AVAILABLE_MINS} minutes" >> ${LOG}
echo >> ${LOG}
return 0 return 0
} }
@ -116,7 +119,6 @@ function create_tarball() {
# #
function delete_tarball() { function delete_tarball() {
if [ -f ${DOWNLOAD_PATH}/${TARBALL} ];then if [ -f ${DOWNLOAD_PATH}/${TARBALL} ];then
log "Start ${AVAILABLE_SECS} seconds timer for deleting ${TARBALL}"
./safeDelete.sh "${DOWNLOAD_PATH}/${TARBALL}" ${AVAILABLE_SECS} & ./safeDelete.sh "${DOWNLOAD_PATH}/${TARBALL}" ${AVAILABLE_SECS} &
else else
log "Cannot find "${DOWNLOAD_PATH}/${TARBALL}" for deleting" log "Cannot find "${DOWNLOAD_PATH}/${TARBALL}" for deleting"
@ -124,27 +126,27 @@ function delete_tarball() {
} }
function add_server_stats() { function add_server_stats() {
log "" echo >> ${LOG}
log " 🍓 SERVER STATUS" log " 🍓 SERVER STATUS"
log "" echo >> ${LOG}
log "Users and Uptime" log " - Users and Uptime"
echo "$(w)" >> ${LOG} echo "$(w)" >> ${LOG}
echo "" >> ${LOG} echo "" >> ${LOG}
log "Disk Usage" log " - Disk Usage"
echo "$(df -h)" >> ${LOG} echo "$(df -h)" >> ${LOG}
echo "" >> ${LOG} echo "" >> ${LOG}
log "Memory Usage" log " - Memory Usage"
echo "$(free -g)" >> ${LOG} echo "$(free -g)" >> ${LOG}
echo "" >> ${LOG} echo "" >> ${LOG}
log "Network Interface" log " - Network Interface"
echo "$(ifconfig eth0)" >> ${LOG} echo "$(ifconfig eth0)" >> ${LOG}
echo "" >> ${LOG} echo "" >> ${LOG}
log "System TOP 10 resources" log " - System TOP 10 resources"
echo "$(ps -eo pid,%cpu,%mem,user,comm --sort=-%cpu | head -n 11)" >> ${LOG} echo "$(ps -eo pid,%cpu,%mem,user,comm --sort=-%cpu | head -n 11)" >> ${LOG}
echo "" >> ${LOG} echo "" >> ${LOG}
} }
@ -181,5 +183,3 @@ function main () {
} }
main main