What kind of window's batch file allows zipping of ftp files?

2

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.

crosenblum

Posted 2011-10-24T15:45:05.960

Reputation: 245

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 – 2011-10-24T17:01:51.120

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 – 2011-10-24T17:15:11.043

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 – 2011-10-25T12:16:18.703

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)

TheLQ

Posted 2011-10-24T15:45:05.960

Reputation: 2 738

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. – Orangutech – 2011-10-24T16:27:57.597

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 – 2011-10-24T16:32:29.087

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 – 2011-10-24T17:02:52.773

@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 – 2011-10-24T17:06:32.933

@TheLQ, because the windows FTP is run in the command prompt, there should not be an issue. – music2myear – 2011-10-24T17:18:56.983

1

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.

Yeodave

Posted 2011-10-24T15:45:05.960

Reputation: 878

0

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)

A T

Posted 2011-10-24T15:45:05.960

Reputation: 641