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

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
 Share

×
×
  • Create New...