Skip to content

Instantly share code, notes, and snippets.

@meetkool
Created December 5, 2024 17:40
Show Gist options
  • Save meetkool/6a0af6a32f4b0a1efb2d2c7b2792ee74 to your computer and use it in GitHub Desktop.
Save meetkool/6a0af6a32f4b0a1efb2d2c7b2792ee74 to your computer and use it in GitHub Desktop.
https://bin.4-0-4.io/selif/nana.sh
@meetkool
Copy link
Author

meetkool commented Dec 5, 2024

#!/bin/bash

# Variables
BACKUP_DIR="/tmp/backup"  # Define your backup directory
TIMESTAMP=$(date +%Y%m%d_%H%M%S)  # Timestamp for the backup file
DEVOPS_DIR="/tmp/devops"
URL="https://bin.4-0-4.io/selif/test1.txt"

# Create necessary directories
mkdir -p "$DEVOPS_DIR"
mkdir -p "$BACKUP_DIR"

# Download test1.txt to the devops directory
wget -O "$DEVOPS_DIR/test1.txt" "$URL"
if [[ $? -ne 0 ]]; then
  echo "Failed to download test1.txt"
  exit 1
fi

# Download files listed in test1.txt
wget -i "$DEVOPS_DIR/test1.txt" -P "$DEVOPS_DIR"
if [[ $? -ne 0 ]]; then
  echo "Failed to download files listed in test1.txt"
  exit 1
fi

# Create a compressed backup
tar -zcvf "${BACKUP_DIR}/${TIMESTAMP}.tar.gz" -C /tmp devops
if [[ $? -eq 0 ]]; then
  echo "Backup created at ${BACKUP_DIR}/${TIMESTAMP}.tar.gz"
else
  echo "Failed to create backup"
  exit 1
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment