Add files via upload
This commit is contained in:
29
log-archive
Normal file
29
log-archive
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# ===== Colors =====
|
||||||
|
GRAY="\e[1;30m"
|
||||||
|
RED="\e[1;31m"
|
||||||
|
GREEN="\e[1;32m"
|
||||||
|
BLUE="\e[1;34m"
|
||||||
|
WHITE="\e[1;37m"
|
||||||
|
RESET="\e[0m"
|
||||||
|
|
||||||
|
# ===== Date and Time =====
|
||||||
|
currentDate=$(date +"%Y%m%d_%H%M%S")
|
||||||
|
|
||||||
|
# ===== Archiving =====
|
||||||
|
if [ $# -eq 1 ] && [ -d "$1" ]; then
|
||||||
|
echo -e "${WHITE}Start archiving...${GRAY}"
|
||||||
|
sudo mkdir -p /var/log/log-archives
|
||||||
|
|
||||||
|
archivePath="/var/log/log-archives/logs-archive_${currentDate}.tar.gz"
|
||||||
|
|
||||||
|
if sudo -k tar -czvf "$archivePath" "$1"/*; then
|
||||||
|
echo -e "${GREEN}The archive has been saved successfully at${RESET} ${BLUE}$archivePath${RESET}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}Archiving failed. Check permissions or disk space.${RESET}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GRAY}Usage:${RESET} ${WHITE}log-archive${RESET} ${BLUE}<log-directory>${RESET}"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
22
setup.sh
Normal file
22
setup.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ===== Colors =====
|
||||||
|
GRAY="\e[1;30m"
|
||||||
|
GREEN="\e[1;32m"
|
||||||
|
BLUE="\e[1;34m"
|
||||||
|
WHITE="\e[1;37m"
|
||||||
|
RESET="\e[0m"
|
||||||
|
|
||||||
|
# ===== Create directory =====
|
||||||
|
echo -e "${GRAY}Creating${RESET} ${BLUE}/var/log/log-archives${RESET} ${GRAY}directory..."
|
||||||
|
sudo mkdir -p /var/log/log-archives
|
||||||
|
|
||||||
|
# ===== Installation =====
|
||||||
|
echo -e "${GRAY}Installing${RESET} ${WHITE}log-archive${RESET} ${GRAY}tool..."
|
||||||
|
sudo cp ./log-archive /usr/bin/
|
||||||
|
sudo chmod +x /usr/bin/log-archive
|
||||||
|
|
||||||
|
# ===== Output =====
|
||||||
|
echo -e "${GREEN}Successfully installed!${RESET}"
|
||||||
|
echo -e "${GRAY}Usage:${RESET} ${WHITE}log-archive${RESET} ${BLUE}<log-directory>${RESET}"
|
||||||
|
echo -e "${GRAY}Stored logs directory:${RESET} ${BLUE}/var/log/logs-archives${RESET}"
|
||||||
Reference in New Issue
Block a user