1

Here's what I'm trying to do:

  1. I need to automate process of copying files from server A to server B. I ideally would like to have a script that is invoked by a cron job periodically on server B.
  2. The files I need to copy are executables and so I need to make sure that no bits are lost during copying.

I have come across command line solutions but I need a programmatic solution. How could I go about doing this?

Ladadadada
  • 26,337
  • 7
  • 59
  • 90
NGambit
  • 153
  • 2
  • 5

3 Answers3

3

rsync, scp. Either one will work, and either are trivial to use "programmatically".

For instance, here's a shell script to copy some files from server-01 to server-02:

(this assumes that key auth is already configured between these servers)

#!/bin/sh

scp -R /path/to/files user@server-01:/path/to/destination

...and an rsync example:

#!/bin/sh

rsync -az /path/to/files user@server-01:/path/to/destination
EEAA
  • 109,363
  • 18
  • 175
  • 245
2

You'll want to use rsync to copy the files. There is a good write up here on how to configure ssh, rsync and cron.

colealtdelete
  • 6,017
  • 2
  • 30
  • 34
0

I like scp/rsync over ssh but also consider serving the files up via http and using wget/curl.

dmourati
  • 25,540
  • 2
  • 42
  • 72