home · contact · privacy
0fb7df79272c7c1b35258093c7028f243935381c
[config] / bookworm / setup_scripts / mirror_dir.sh
1 #!/bin/sh
2 # Mirror directory tree from remote to local server, keeping the path.
3 set -e
4
5 expect_n_args 2 "(server, directory)" "$@"
6 server=$1
7 dir=$2
8 path_package=/tmp/delete.tar
9
10 eval `ssh-agent`
11 ssh-add
12 cd
13 ssh plom@"${server}" "cd \"${dir}\" && tar cf ${path_package} ."
14 scp plom@"${server}":"${path_package}" "${path_package}"
15 mkdir -p "${dir}"
16 cd "${dir}"
17 tar xf "${path_package}"
18 cd
19 rm "${path_package}"
20 ssh plom@"${server}" rm "${path_package}"