Add bash scripts

This commit is contained in:
2025-10-14 21:38:29 +02:00
commit 0d07d33c59
6 changed files with 88 additions and 0 deletions

31
scripts/backup.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -e
ARCHIVE="/home/ubuntu/backup.tar.gz"
LOG_DIRECTORY="/home/ubuntu/logs"
if ! [[ -d "$LOG_DIRECTORY" ]]; then
echo "Log directory not found: $LOG_DIRECTORY"
exit 1
fi
log_count=0
for file in "$LOG_DIRECTORY"/*.log; do
if [[ -f "$file" ]]; then
log_count=$(( log_count + 1 ))
fi
done
echo "Found $log_count log files."
if (( log_count > 0 )); then
tar czf "$ARCHIVE" "$LOG_DIRECTORY"/*.log
echo "Successfully created archive: $ARCHIVE"
else
echo "No files found, skipping backup."
fi