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!

2 Answers 2

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/
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.

2
  • Possibly by comparing the file names first? But how I'll do that practically...
    – laurens
    Nov 12, 2009 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, 2009 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .