18 lines
549 B
Bash
Executable File
18 lines
549 B
Bash
Executable File
#!/bin/bash
|
|
# $1 -> hash sync
|
|
# $2 -> LOCAL PATH -> /home/luca/test/
|
|
# $3 -> REMOTE PATH -> notanamber@myvps:/home/notanamber/sydir/ [avoid to copy remote in source]
|
|
sync() {
|
|
src=$2
|
|
dest=$3
|
|
otheropts=$4
|
|
LOGFILE=~/syncdir_$1.log
|
|
if [ ! -f $LOGFILE ]; then
|
|
touch $LOGFILE
|
|
fi
|
|
# PUSH TO REMOTE - and PULL FROM REMOTE swapping `src` with `dest`
|
|
echo "executing rsync -aP --log-file=$LOGFILE -e ssh $otheropts $src $dest"
|
|
# NOTE REMOTEDIR ALREADY EXISTS IN DESTINATION
|
|
rsync -aP --log-file=$LOGFILE -e ssh $otheropts $src $dest
|
|
}
|