remove test file. change sync to copy

This commit is contained in:
Radek
2025-03-05 14:58:26 +00:00
parent 830dc7cdc3
commit 7ff660ba90

View File

@@ -5,10 +5,11 @@ cd /opt/AZURE || exit 1
# Configurable variables # Configurable variables
# Basic variables need for this scrip[t to operate correctly. # Basic variables need for this scrip[t to operate correctly.
BUSINESS_HOURS_START=10 BUSINESS_HOURS_START=16
BUSINESS_HOURS_END=20 BUSINESS_HOURS_END=20
AZURE_ACCOUNT="" AZURE_ACCOUNT=""
AZURE_SAS="" AZURE_SAS=""
LOCK_FILE="/tmp/run_azcopy.lock" LOCK_FILE="/tmp/run_azcopy.lock"
# Arguments # Arguments
@@ -90,23 +91,15 @@ for LINE in "${SYNC_JOBS[@]}"; do
DEST_URL="$AZURE_ACCOUNT/$DEST_CONTAINER" DEST_URL="$AZURE_ACCOUNT/$DEST_CONTAINER"
echo "Syncing $SOURCE_DIR to container: $DEST_CONTAINER" | tee -a "$LOG_FILE" echo "Syncing $SOURCE_DIR to container: $DEST_CONTAINER" | tee -a "$LOG_FILE"
# Check if the container exists by attempting to write a small test file
TEST_FILE="$SOURCE_DIR/.azcopy_test_file"
touch "$TEST_FILE"
azcopy cp "$TEST_FILE" "$DEST_URL?$AZURE_SAS" > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "ERROR: Destination container $DEST_CONTAINER does not exist or is inaccessible. Exiting." | tee -a "$LOG_FILE"
rm -f "$TEST_FILE"
rm -f "$LOCK_FILE"
exit 1
fi
rm -f "$TEST_FILE"
# Run azcopy in the background (one directory at a time) # Run azcopy in the background (one directory at a time)
if [[ "$LOGGING" == "true" ]]; then if [[ "$LOGGING" == "true" ]]; then
azcopy sync "$SOURCE_DIR" "$DEST_URL?$AZURE_SAS" --recursive --cap-mbps "$BANDWIDTH_CAP" | tee -a "$LOG_FILE" & # @05-03-2025 testing copy instead of sync due to issues after archiving files in the blob
# azcopy sync "$SOURCE_DIR" "$DEST_URL?$AZURE_SAS" --recursive --cap-mbps "$BANDWIDTH_CAP" | tee -a "$LOG_FILE" &
azcopy copy "$SOURCE_DIR" "$DEST_URL?$AZURE_SAS" --overwrite false --recursive --cap-mbps "$BANDWIDTH_CAP" | tee -a "$LOG_FILE" &
else else
azcopy sync "$SOURCE_DIR" "$DEST_URL?$AZURE_SAS" --recursive --cap-mbps "$BANDWIDTH_CAP" > /dev/null 2>&1 & # @05-03-2025 testing copy instead of sync due to issues after archiving files in the blob
# azcopy sync "$SOURCE_DIR" "$DEST_URL?$AZURE_SAS" --recursive --cap-mbps "$BANDWIDTH_CAP" > /dev/null 2>&1 &
azcopy copy "$SOURCE_DIR" "$DEST_URL?$AZURE_SAS" --overwrite false --recursive --cap-mbps "$BANDWIDTH_CAP" > /dev/null 2>&1 &
fi fi
AZCOPY_PID=$! AZCOPY_PID=$!