Files
freeplanet_serverside/scripts/docker_copia_da_a.sh
2024-09-17 17:38:47 +02:00

30 lines
728 B
Bash

#!/bin/bash
# Ensure two arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <source_directory> <destination_directory>"
exit 1
fi
DIR_ORIG=$1
DIR_DEST=$2
# Check if the source directory exists
if [ ! -d "$DIR_ORIG" ]; then
echo "Error: Source directory '$DIR_ORIG' does not exist."
exit 1
fi
# Create the destination directory if it doesn't exist
#mkdir -p "$DIR_DEST"
# Run the Docker command to copy files
docker run --rm -v "$DIR_ORIG":/from -v "$DIR_DEST":/to alpine ash -c "cp -av /from/. /to"
# Check if the Docker command was successful
if [ $? -eq 0 ]; then
echo "Files copied successfully from '$DIR_ORIG' to '$DIR_DEST'."
else
echo "Error: Failed to copy files."
exit 1
fi