Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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

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 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
add comment

Your Answer

 
discard

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.