Jump to content

Anyway to sync directories over ssh?


fuzzylizard
 Share

Recommended Posts

I am not sure if this is suppose to go here, but I am looking for a way to sync directories over ssh.

 

I have my home directory at school and a similiar directory at home. I would like to be able to sync these two directories so that they are the same. However, I can only access my school directory from home using ssh or sftp.

 

Is there a sync command built into ssh somewhere that will accomplish what I want?

 

Thanks.

Link to comment
Share on other sites

rsync is what you want, it can work through ssh if this enviroment variable is set:

export RSYNC_RSH="ssh"

 

For example:

#!/bin/bash



sincronizar () {

    usage="Usage: sincronizar "local directory" "remote directory""

    local="${1?$usage}"

    remote="${2?usage}"

    command="rsync -avuzb --exclude '*~'"

    $command $remote $local

    $command $local $remote

}



sincronizar "${HOME}/bin" "arusabal@slack_machine:/binaries"

 

I use cron with something similar to the above code to syncronize directories between my two machines

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...