Backup Files Using FTP Commands

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
sailor dude
Pro Scripter
Posts: 50
Joined: Fri Jan 20, 2006 10:43 pm

Backup Files Using FTP Commands

Post by sailor dude » Fri Jan 20, 2006 11:51 pm

First, I can't say enough good things about Macro Scheduler. I have written over 50 macros using Macro Scheduler that I use every day.

However, I tried to write a macro to backup a PC to a server using FTP. I needed to back up a scattered list of about 1,000 files in 100 folders to 100 different folders (I had too many rules). I tried 6 approaches using FTPPutFile, DOS FTP, windows explorer and VBScript. I gave up.

What an ugly task it turned out to be. If you have a similar task to perform, do not use Macro Scheduler. It is the wrong tool. It happens.

FTPPutFile can only handle 1 file at a time. The file handling commands in Macro Scheduler are somewhat limited to easily process many files in many folders. However, there is some example code on this forum that helps handle this task.

DOS FTP and MoveItFreely are awkward to use due to the lack of windows exposure due to its DOS nature. For example, for error and status checking you could pipe the result of a DOS FTP session to an ascii file and have Macro Scheduler open that file and process it. Similarly, you can create an ascii file that contains the commands to process in a FTP session. It's ugly though.

Using windows explorer isn't too bad but there are some subtle, time consuming syntax issues to overcome. Here is the command to launch explorer and start an FTP session in a given directory

Run>explorer.exe ftp://username:[email protected]//Folder/Folder

How much time would it take you to find the syntax that worked?

Using windows explorer would be the way to go if I were more proficient using VBScript and COM. Windows explorer does not lend itself well to Macro Scheduler key press and mouse emulation.

VBScript on its own has similar issues as using Macro Scheduler FTPPutFile.

Then, there is the issue of developing a user interface to select the files and folders to be created. I could have created a Dialog with check boxes and buttons to select files. I copuld have created a macro to use to create an ascii file listing of the names of files to be moved and where they needed to be copied to. In my case, the folder structure on the server side is different than the client side.

You are beginning to see the complexity.

After trying several commercial products. I decided to use a freeware/commercial product called SyncBack. It looks like a powerful tool in both freeware and commercial versions.

I do not have any commercial interest in any of the companies mentioned.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun Jan 22, 2006 8:38 pm

The way I would approach this would be to zip up the files to be backed up, using the command line options of WinZip or PKZip and then have only one file, or fewer files, to upload using FTPPutFile. This is only one way to do it. Another would be to create an FTP command file on the fly (assuming the files and locations change - if not you only need do it once) and then you just run cmd.exe /c ftp .... once. Automating DOS FTP is the best approach as all you need is an ftp command file which is passed to the ftp command line. There are examples on this forum.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts