Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question

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/* \
share|improve this answer

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.

share|improve this answer
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 /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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.