Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What commands should I use to transfer a file via FTP and then compress the files in a backup directory with a filename containing the date/time for reference?

I'd prefer to use batch scripting.

The FTP location is on my home network and the files will be copied to a Windows XP sp3 box.

The compression is merely for archival purposes, not to lessen the transfer size.

share|improve this question
    
The ftp location is on my home network, I just want a batch file to help me make zipped backups of files on that machine. Thank you. –  crosenblum Oct 24 '11 at 17:01
    
Ok, so then the question is not whether you can compress PRIOR to transfer, but whether you can transfer AND compress in the same script, to which the answer is of course yes. It's simply a matter of stringing together the correct commands in the correct order. –  music2myear Oct 24 '11 at 17:15
    
If the ftp location is on your local network, could you not just share the folder in Windows and use a copy command from a UNC path? Take ftp out of the equation. –  Yeodave Oct 25 '11 at 12:16

3 Answers 3

With only your XP machine you'll have to download the contents of the FTP location then ZIP it up, not ZIP then download.

You can download the contents with winscp then ZIP with your favorite program (I know 7-zip can do this)

share|improve this answer
    
Unless you have some sort of other access to the FTP server (SSH commandline or whatnot) to issue commands remotely, or schedule a task to run server-side, the above is correct. Copy down to temp, compress, then delete temp. –  Scandalon Oct 24 '11 at 16:27
    
Are there CLI ftp applications that support GZIP or BZIP or similar prior to transfer or is that a function, once again, of controlling the remove server? –  music2myear Oct 24 '11 at 16:32
    
Why winscp? Can't I just use some command line ftp command to login, copy the files over, then zip and rename em? This machine is on my local network, via wifi. –  crosenblum Oct 24 '11 at 17:02
    
@crosenblum I don't think you can script the Windows FTP program to download files and folders like that. I could be wrong though –  TheLQ Oct 24 '11 at 17:06
    
@TheLQ, because the windows FTP is run in the command prompt, there should not be an issue. –  music2myear Oct 24 '11 at 17:18

A batch file can do this.

You can use Windows XP's ftp Command to connect to your ftp site and then get your content. See this > http://www.robvanderwoude.com/ftp.php You need to create an unattended ftp script (a separate text file containing your Ftp commands).

So in the batch file you'd put something like: ftp -s:ftpcommands.txt hostName

and in the ftpcommands.txt you'd put:

username
password
(CD, GET or whatever)

You can then use the command line interface of any zip program you like to do what it needs to do and the xcopy command to move the archive to your backup folder.

share|improve this answer

Check the %date% and %time% variables.

Then use the compress program from microsoft to zip/unzip.

Alternatively for zip and unzip operations, use the open-source CLI 7za (7-zip)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.