Linux
BASH
Logs Backup Blob

curl -sL https://aka.ms/InstallAzureCLIDeb (opens in a new tab) | sudo bash

#!/bin/bash set -xe

Configuration

LOG_DIR="/var/www/logs" AZURE_STORAGE_ACCOUNT="" AZURE_CONTAINER_NAME="" SAS_TOKEN="" SERVER_IP="$(curl -s ifconfig.me)" DATE="$(date +%Y-%m-%d)"

Upload logs older than 24 hours from LOG_DIR

find "$LOG_DIR" -type f -mtime +0 | while read file; do az storage blob upload
--account-name "$AZURE_STORAGE_ACCOUNT"
--container-name "$AZURE_CONTAINER_NAME"
--file "$file"
--name "DATE-$DATE/SERVER-IP-$SERVER_IP/$(basename "$file")"
--sas-token "$SAS_TOKEN"
--overwrite done

Optional: Delete original logs after upload (Uncomment if needed)

find "$LOG_DIR" -type f -mtime +0 -delete

echo "Backup completed successfully."

#############################################################################

#!/bin/bash set -xe

Configuration

LOG_DIR="/var/log" AZURE_STORAGE_ACCOUNT="" AZURE_CONTAINER_NAME="" SAS_TOKEN="" SERVER_IP="$(curl -s ifconfig.me)" DATE="$(date +%Y-%m-%d)"

Upload logs older than 24 hours

find "$LOG_DIR" -type f -mtime +0 | while read file; do az storage blob upload
--account-name "$AZURE_STORAGE_ACCOUNT"
--container-name "$AZURE_CONTAINER_NAME"
--file "$file"
--name "DATE-$DATE/SERVER-IP-$SERVER_IP/$(basename "$file")"
--sas-token "$SAS_TOKEN"
--overwrite done

Optional: Delete original logs after upload (Uncomment if needed)

find "$LOG_DIR" -type f -mtime +0 -delete

echo "Backup completed successfully."

#############################################################################

#!/bin/bash set -xe

Configuration

LOG_DIR="/var/log" AZURE_STORAGE_ACCOUNT="" AZURE_CONTAINER_NAME="" SAS_TOKEN="" SERVER_IP="$(curl -s ifconfig.me)" DATE="$(date +%Y-%m-%d)"

Upload logs older than 24 hours

find "$LOG_DIR" -type f -mtime +0 | while read file; do az storage blob upload
--account-name "$AZURE_STORAGE_ACCOUNT"
--container-name "$AZURE_CONTAINER_NAME"
--file "$file"
--name "DATE-$DATE/SERVER-IP-$SERVER_IP/$(basename "$file")"
--sas-token "$SAS_TOKEN"
--overwrite done

Optional: Delete original logs after upload (Uncomment if needed)

find "$LOG_DIR" -type f -mtime +0 -delete

echo "Backup completed successfully."


🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!