I'm trying to mirror copy the whole directory from one cluster to another cluster right now. But it fails when there is a space in the name and I can't figure out how to solve this problem because it seems scp thinks I'm copying multiple files. I'm using a variable to flag the path that I need so it seems it would not be easily solved by adding a back slash.
This is the code that I'm using:
if ssh user@ip -i key test -d "'$current_dir'"; then
echo "Directory exists. Ready to copy $dir_name."
scp -i key -r "$current_dir/$dir_name" user@$ip:"$current_dir/$dir_name"
else
echo Directory doesn\'t exist. Making a new directory.
ssh user@$ip -i key mkdir "'$current_dir'"
scp -i key -r "$current_dir/$dir_name" user@$ip:"$current_dir/$dir_name"
fi
I have tried single quote, double quotes and single quote with double quotes, but none of them works. Can anyone help me solve it? By the way, the mkdir statement in the code works.