Problem
I have code that first iterates through a file with a folder path per line ensuring they are correct (which it does pass, and I also know these to be valid paths), and then tries to pass it to the program borg
but errors.
The problem seems to be all down to how I'm creating or using folderList
(which you can see as the first echo) but I'm not sure how to fix it.
Input
/media/sf_D_DRIVE/VirtualMachines Backups/
/media/sf_C_DRIVE/Websites/47/sln/site/App_Data/
Error Output
"/media/sf_D_DRIVE/VirtualMachines Backups/" "/media/sf_C_DRIVE/Websites/47/sln/site/App_Data/"
"/media/sf_D_DRIVE/VirtualMachines: [Errno 2] No such file or directory: '"/media/sf_D_DRIVE/VirtualMachines'
Backups/": [Errno 2] No such file or directory: 'Backups/"'
"/media/sf_C_DRIVE/Websites/47/sln/site/App_Data/": [Errno 2] No such file or directory: '"/media/sf_C_DRIVE/Websites/47/sln/site/App_Data/"'
Code
#this snippet reads in folder paths from a file
while read line
do
exists=false
if [ -f "$line" ]; then
exists=true
fi
if [ -d "$line" ]; then
exists=true
fi
if [ $exists = false ]; then
exit 1
fi
folderList+=" $line"
done < "$2"
echo $folderList #gets past here successfully
borg create -s --progress $1::${dateString} $folderList