Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Batch/Shell script to download backups through FTP
New Posts  All Forums:Forum Nav:

Batch/Shell script to download backups through FTP

post #1 of 4
Thread Starter 
Hi All,

I'm trying to create a simple batch/shell script to complete the following:

1. Connect to FTP Point 1 (Using log-in credentials)
2. Download pre defined files and folders within the root folder its connected to (displaying size and % it's downloading etc, speed would be a bonus to)
3. END
4. Connect to FTP point 2 (Using its own log-in credentials)
5. Download pre defined files and folders within the root folder its connected to (displaying size and % it's downloading etc, speed would be a bonus to)
6. END

I then want to automate this daily perhaps using cron jobs?

It will be a Windows XP or possibly linux connecting to a Windows Server FTP in both situations.

Can this be done and how would I go about this?

Box box it runs off will be set-up fresh then just left in a corner and left to tick over so this needs to be fully automated without prompts.

Help really appreciated on this.

Read so many articles im all confused! So much different info around sometimes you can just go way to far into it for what should be a relatively easy task!!!

Thanks.


EDIT: In one of the download instances above, it would be great if it could check what files it has already and just downloading the new ones ... and in the second instance download the same group of files but in new folders with an incrementing number so "Backup 12/12/2011 #1 ... Backup 12/12/2011 #2 ... Backup 13/12/2011 #1 ... etc"
post #2 of 4
FTP scripting is usually pretty hokey since you have to put a plaintext password somewhere if you're doing it in shell/batch. Are you okay with that being part of your process? Are you able to set up SFTP with shared keys?
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
post #3 of 4
rsync
Akiyama Mio
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6420 @ stock, 0.98v Asus P5N-E SLI Gainward GTX 460 1GB @ 800/1600/1900 2x2GB Kingston @ 800MHz 5-5-5-15 2T 
Hard DriveOptical DriveOSMonitor
WD 250GB, 320GB SATA/3, 16MB Cache, Seagate 1TB LG GSA-H62N 18x SATA Ubuntu 9.10 x86 & Win7 x86 Asus VW222U 
KeyboardPowerCase
Logitech Classic Corsair 650HX NZXT Apollo Black 
  hide details  
Reply
Akiyama Mio
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6420 @ stock, 0.98v Asus P5N-E SLI Gainward GTX 460 1GB @ 800/1600/1900 2x2GB Kingston @ 800MHz 5-5-5-15 2T 
Hard DriveOptical DriveOSMonitor
WD 250GB, 320GB SATA/3, 16MB Cache, Seagate 1TB LG GSA-H62N 18x SATA Ubuntu 9.10 x86 & Win7 x86 Asus VW222U 
KeyboardPowerCase
Logitech Classic Corsair 650HX NZXT Apollo Black 
  hide details  
Reply
post #4 of 4
Something like rsync is a far more elegant solution, and secure. But if you for some reason must use ftp:
Code:
#!/bin/bash

filename="/home/paul/myfile.tar.gz"
hostname="ftp.myhost.com"
username="username"
password="password"
ftp -un $hostname <<EOF
quote USER $username
quote PASS $password

binary
put $filename
quit
EOF
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Batch/Shell script to download backups through FTP