From: Christian Heller Date: Fri, 14 Dec 2018 23:21:14 +0000 (+0100) Subject: Add a script to mirror directory trees. X-Git-Url: https://plomlompom.com/repos/feed.xml?a=commitdiff_plain;h=75be7235258390736996362e04beda1650fc1b4a;hp=f104d3d88085c7a3a7685411e622f21e7c68aaff;p=config Add a script to mirror directory trees. --- diff --git a/all_new_2018/mirror_dir.sh b/all_new_2018/mirror_dir.sh new file mode 100755 index 0000000..688b2b8 --- /dev/null +++ b/all_new_2018/mirror_dir.sh @@ -0,0 +1,22 @@ +#!/bin/sh +set -e + +if [ $# -lt 2 ]; then + echo "Need server and directory as arguments." + false +fi +server=$1 +dir=$2 +path_package=/tmp/delete.tar + +eval `ssh-agent` +ssh-add +cd +ssh plom@"${server}" "cd \"${dir}\" && tar cf ${path_package} ." +scp plom@"${server}":"${path_package}" . +mkdir -p "${dir}" +cd "${dir}" +tar xf "${path_package}" +cd +rm "${path_package}" +ssh plom@"${server}" rm "${path_package}"