Friday, July 01, 2005

Scheduling FTP to FTP Server in Windows

This example will use built-in features of Windows, so no additional software is needed. One feature is the "Scheduled Tasks" Control Panel and the other is the executable program FTP.EXE.

Part I - Creating the FTP script
FTP scripts automate the process of using FTP servers like ftp.keekar.com. The script file is just a list of FTP commands saved in a standard text file.

1. Open Notepad
2. Copy and paste this template script into the new Notepad document:

open ftp.keekar.com
username
password
prompt
passive
cd files/backup_directory_name/
lcd "C:\Path of local directory to backup"
mput *.*
bye

3. Replace username on line 2 with your ftp server username.
4. Replace password on line 3 with your ftp server password.
5. Replace backup_directory_name in line 6 with the name of directory in your ftp server to which you wish to your files.
6. Replace "C:\Path of local directory to backup" in line 7 with the path to the directory on your local computer that contains the files you wish to backup. As shown in the example, you will need to enclose the entire directory path in quotes if it contains any spaces. A typical path may look like:
"C:\Documents and Settings\JohnDoe\My Documents"
7. Replace *.* in line 7 with a list of files you wish to backup (within the directory you just specified in step 6). If you leave line 7 unchanged, all files contained in the directory will be uploaded. Please note that the contents of any further subdirectories will not be included.
8. Save the FTP script and exit Notepad. A good name and location for it might be:
C:\keekar_backup_script.txt
9. If you are interested to do binary transfer then introduce bin prior to mput.

Part II - Scheduling the script to run at certain times

1. Open the "Scheduled Tasks" Control Panel.
2. Chose "New > Scheduled Task" from the "File" menu.
3. Type a name for the task. A good name might be: Keekar Backup
4. Double-click the new task.
5. In the field labeled "Run:" type:
C:\WINNT\system32\FTP.EXE –s:C:\keekar_backup_script.txt
(If you choose a different name or location for your FTP script is step 8 of Part I, you'll need to replace C:\keekar_backup_script.txt with the full path to the script.)
6. In the field labeled "Start in:" type:
C:\WINNT\system32
7. Click the "Schedule" tab.
8. To schedule the backup to occur every day at midnight, you would set the drop-down menu labeled "Schedule Task:" to Daily, and the field labeled "Start Time:" to 12:00 AM.
9. Once you have choosen your schedule, click the "Okay" button.
10. Close the "Scheduled Tasks" Control Panel.

If you know little bit about the batch scripting then u can perform lots of other things too. Like checks for files availability, monitoring the time taken by each transfer etc.

No comments: