Reputation: 1101
I'm using a Bash script to backup my webfiles via FTP. As the title says, I have an Ubuntu webserver and am backing up to a Windows machine. I have an ssh program and FileZilla Server on the Windows machine, and can SSH and SFTP into it. The core of the script looks like this:
SRCDIR="C:\\Users\\Tech1\\testserverbackup"
DATAIN="/var/www/html/"
FILENAME="-r *"
sshpass -e sftp -oBatchMode=no -b - ${USER}@${LANHOST} << EOF
cd ${SRCDIR}
lcd ${DATAIN}
mkdir $(date -I)
cd $(date -I)
put ${FILENAME}
bye
echo made it
EOF
The others vars are a bit sensitive, so I don't want to post them, but the credentials have been working for me so far.
The error I'm getting looks like this:
sftp> cd C:\Users\Tech1\testserverbackup
Couldn't stat remote file: No such file or directory
I've ssh'd into the folder and sftp'd, so I'm not really sure what the issue is. AFAIK, cd is the native windows command, not just the FTP one.
Any ideas what's going wrong? Thank you.
Upvotes: 3
Views: 26705
Reputation: 39
You make change the ownership of this directory in the Linux:
$ sudo chown $USER /path/directory
I found this solution here.
Upvotes: 0
Reputation: 3863
sftp> cd C:\Users\Tech1\testserverbackup
Couldn't stat remote file: No such file or directory
This is due to FTP servers not having the concept of drive letters for mounts, as Windows systems do.
You can use pwd
to while connected to FTP to determine the directory you're currently in:
sftp> pwd
/C/Users/Tech1
...which shows that in your environment, the FTP administrator mapped a Windows C:
drive to a regular folder called C
within the FTP server (and mapped all the other mounted drives to folders).
Upvotes: 1