Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8677
  • Last Modified:

XCOPY and FTP: can they work together?

I currently use XCOPY in my office to mirror the contents of HardDrive1 from Z: in ComputerA to L: in ComputerB.  This works fine using the following commands:

C:\WINNT\system32\XCOPY "Z:\" "L:\Friday" /Y /E /D
C:\WINNT\system32\ATTRIB -h -s "L:\Friday"

What I would like to be able to do is XCOPY my files to an FTP location instead of simply some mapped harddrive here in the office.  Is that some way I can alter the XCOPY command so that it will mirror a drive's contents on an FTP site?

Thank you for any assistance you may be able to offer.
0
DanielAttard
Asked:
DanielAttard
  • 5
  • 4
1 Solution
 
GuruGaryCommented:
I use NCFTPPUT for operations like that (http://www.ncftp.com/ncftp/).

It could be done with a batch file using only native commands, but it would take a lot of code, compared to one line with NCFTP.  Take a look at NCFTPPUT to see if that would work.  If it looks OK, then I will be glad to help with the syntax.  
0
 
For-SoftCommented:
No. The XCOPY command will not work with FTP. There is no way to force XCOPY to do it.
But, it could be possible to create a batch file doing the same job using an FTP command. Such a solution would require Windows NT/2000/XP. And it would not be an easy one to make.

It would be a better solution to find a proper utility for tasks like that.
0
 
DanielAttardAuthor Commented:
Thanks for the suggestions.

GuruGary, I think that NCFTPPUT looks like it should work.  How would I begin with using it?  I'm not that familiar with running programs simply from the command prompt.

thanks.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
GuruGaryCommented:
1) Download NCFTP from http://www.ncftp.com/download/ (be sure to download the Windows version)
2) Install NCFTP from the downloaded file
3) Get your FTP username, password, hostname, and remote / local directory information, and put it in the script below

@echo off
setlocal
set FTPUSER=username
set FTPPASS=password
set FTPHOST=ftp.domain.com
set REMOTEDIR=/ftp/path/to/destination
set LOCALPATH="Z:\*.*"
ncftpput -u %FTPUSER% -p %FTPPASS% -mRS _tmp %FTPHOST% /ncftest %LOCALPATH%

Note that you can not typically control file timestamps through FTP, so I don't know of a replacement for your xcopy /D through NCFTP or any other FTP program.
0
 
DanielAttardAuthor Commented:
Thanky Gary.  I think I'm almost there.  I have downloaded and installed the windows version of NCFTP.  I have saved a notepad file as test.cmd.  The file contains the following:

@echo off
setlocal
set FTPUSER=domain.ca
set FTPPASS=xxxxxxx
set FTPHOST=ftp.domain.ca
set REMOTEDIR=/98/
set LOCALPATH="Z:\98\*.*"
ncftpput -u %FTPUSER% -p %FTPPASS% -mRS _tmp %FTPHOST% /ncftest %LOCALPATH%

When I double-click the file to launch the script, a dos window opens and briefly runs through each of the files in the localpath.  It appears to show the full path, the file size, and then the rate per second of the transfer.  It appears to be working, but when I look in the remotedir, the files are not there.  I must not be specifying the remotedir correctly.  When I am in the remotedir in windows explorer, the path reads:

ftp://ftp.domain.ca/98/

What then, would the correct syntax be for the REMOTEDIR?

thanks
0
 
GuruGaryCommented:
Oops.  My fault.  I left some of my test code in there.  Change the ncftpput line to:

ncftpput -u %FTPUSER% -p %FTPPASS% -mRyS _tmp %FTPHOST% %REMOTEDIR% %LOCALPATH%

So right now the files are probably in the remote directory /ncftest which I accidentally left hard-coded in the script.  The change above will allow the ncftpput to use the folder you specified
0
 
DanielAttardAuthor Commented:
Thanks again Gary.  I noticed one small difference between your first and second examples of the ncftpput lines.  The first example reads:

-mRS _tmp

and then the second line reads:

-mRyS _tmp

There is a 'y' present in the second line.  Was that intended?  What do those parameters mean?

0
 
GuruGaryCommented:
The 'y' attempts to keep the timestamp when it moves the file, but most FTP servers don't support this.  It won't hurt to try it, but chances of it actually preserving the timestamp are very slim.
0
 
DanielAttardAuthor Commented:
Success!  Thank you so much Gary.  It appears to be working like a charm, although it is unfortunate that this process does not maintain the timestamp.  

One last question, then I promise I will be done.  If the LocalPath contains 10.0 GB of information, then obviously the first time I run the script, it will transfer 10.0 GB to the RemoteDir.  My question is:  What happens the next time I run the script, when the LocalPath then contains 10.1 GB of information?  Will this script transfer the entire 10.1 GB of information, or will it only send the additional 0.1 GB?  Considering that the transfer process does not retain the original timestamp, my guess is that this script will transfer *all* the information, *all* the time because it will not have any method of comparing the original file contents with the new file contents.  This seems to be a highly inefficient process, if what I am thinking is true.

Is it possible to write the script so that it performs only an incremental/differential FTP transfer?

Thanks again.
0
 
GuruGaryCommented:
FTP servers (typically) do not let an FTP client change timestamp information ... so using FTP there is not a way to do in incremental or differential FTP transfer.  Which means that it would transfer the entire 10.1 GB of information each time. The only way to achieve those results would be to track that information on the client side.

It probably wouldn't be too hard to write a batch file to only pass files to FTP that have the Archive bit has been set, and after FTPing a file, then turn off the archive bit.  If we do that, then the timestamps on the FTP server are still going to show the date / time of when they were transferred to the server.  If you think that will work, or if you have other ideas then let me know and I can help with a script for that also.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now