1

I would need a bash script to transfer folders recursively via FTP. Username/password/IP - static defined.

  1. Server where the script runs on: Linux
  2. Source server: Samba (Linux...)
  3. Dest. Server: Linux

As the files to be transferred are big database files (.bak, etc) overwriting should be avoided. Preferably no prompting because the script has to be 'cronned', to run at night.

(I'm not a hero in bash, but I have the impression it's the easiest for this situation)

Thanks a bunch in advance!

Sam Cogan
  • 38,736
  • 6
  • 78
  • 114
laurens
  • 397
  • 4
  • 19

2 Answers2

4

If the destination server is Linux might I suggest just using rsync with an ssh key? FTP is unencrypted and doesn't have native support for incremental backups.

A single rsync with a command line such as the below could suffice.

rsync -auv -e "ssh -i /path/to/keyfile" /path/to/source_directory/* \
    user@remotehost:/path/to/destination_directory/
Kyle Smith
  • 9,683
  • 1
  • 31
  • 32
0

You can mount FTPfs and cp everything there. Make sure you disable delta-transfer so it doesn't download files from there :)

BTW, how are you going to make these backups without overwriting? you'll have a bunch of old files mixed with some new ones if you don't use date in folder name.

kolypto
  • 11,058
  • 12
  • 54
  • 66
  • Possibly by comparing the file names first? But how I'll do that practically... – laurens Nov 12 '09 at 13:50
  • Install FTPfs, and mount FTPfs somewhere (for instance, /mnt/backup: `curlftpfs ftp://ftp.sunet.se/ /mnt/backup`). Then set this to cron: `cp -R -n /i/wanna/backup/this /mnt/backup/ > /dev/null` – kolypto Nov 12 '09 at 15:40