My Scripts Collection

backup_dotfiles.sh

Bash

A simple Bash script to automatically back up important dotfiles to a specified directory or remote server.

#!/bin/bash
# Script to backup dotfiles
# Destination directory
DEST_DIR="~/backups/dotfiles"
# Files to backup
DOTFILES=( ".bashrc" ".vimrc" ".gitconfig" )

# Create destination if it doesn't exist
mkdir -p "$DEST_DIR"

# Copy files
for file in "${DOTFILES[@]}"; do
  cp ~/"$file" "$DEST_DIR/"
  echo "Backed up $file to $DEST_DIR"
done

echo "Dotfile backup complete!"
View on GitHub Download Script

server_monitor.py

Python

Python script to monitor server health (CPU, RAM, Disk) and send alerts via email if thresholds are breached.

import psutil
import smtplib

# Thresholds
CPU_THRESH = 80.0  # percent
RAM_THRESH = 85.0  # percent

def check_cpu():
    cpu_usage = psutil.cpu_percent(interval=1)
    if cpu_usage > CPU_THRESH:
        send_alert(f"High CPU Usage: {cpu_usage}%")

# ... (rest of the script, including send_alert function) ...

# if __name__ == "__main__":
#    check_cpu()
#    # check_ram() etc.
View on GitHub