home · contact · privacy
Add a script to mirror directory trees.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 14 Dec 2018 23:21:14 +0000 (00:21 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 14 Dec 2018 23:21:14 +0000 (00:21 +0100)
all_new_2018/mirror_dir.sh [new file with mode: 0755]

diff --git a/all_new_2018/mirror_dir.sh b/all_new_2018/mirror_dir.sh
new file mode 100755 (executable)
index 0000000..688b2b8
--- /dev/null
@@ -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}"