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