Jump to content

SSH Copy Script


Recommended Posts

I need to make a script that will connect through SSH with Putty or WinSC application to a server which is in Germany.

Basically, one server is in Croatia and another is in Germany. When I make a connection between those two servers, I need to copy contents of one folder to Germany and vice versa.

What is the best way to do this using Putty or WinSC. A log would be also needed for this..

Thx

Link to comment
Share on other sites

  • 2 months later...

Hi,

The first question that comes to mind is how often you will need to copy the files from one server to another. I am making a few assumptions here so bear with me. If I re-state things you already know please do not take offense as I am just trying to spell out my logic in how I would decide to administer this situation.

If you are doing frequent file copies I would suggest using a shell script that kicks off scp and copies the files for you. You can use the crontab functionality to execute the shell script. Conversely if you only need to copy the files a few times then WinSCP may be a better choice as it allows you to see the source and destination directories and to select multiple files at once to be copied even with different file extensions.

Secondly, if you are going to scp the files directly from the source server to the destination server you would want to do the following:

scp -v file.txt username@domain.com:/remote/directory >> var/log/scp.log

If you are copying the files from Croatia to Germany from your computer you would want to use Putty's pscp.exe to do the following:

scp -v username@domain.com:/remote/directory1/file.txt \ username@domain.com:/remote/directory2/ >> var/log/scp.log

Both these commands will execute the copies you need and will log the results to the file and directory listed above.

Hope this helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...