From 75be7235258390736996362e04beda1650fc1b4a Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 15 Dec 2018 00:21:14 +0100 Subject: [PATCH] Add a script to mirror directory trees. --- all_new_2018/mirror_dir.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 all_new_2018/mirror_dir.sh 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}" -- 2.30.2