From: Christian Heller Date: Fri, 27 Mar 2020 21:22:25 +0000 (+0100) Subject: Add borg repo mirroring. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7Bprefix%7D%7D/bar%20baz.html?a=commitdiff_plain;h=40b1aac9fad6b73589484750bc70968a260f945e;p=config Add borg repo mirroring. --- diff --git a/buster/other_files/plomlombot_daemon.sh b/buster/other_files/plomlombot_daemon.sh index 8cf58a1..2f267bd 100755 --- a/buster/other_files/plomlombot_daemon.sh +++ b/buster/other_files/plomlombot_daemon.sh @@ -41,7 +41,7 @@ while true; do ln -sfn "${logs_dir}" "${irclogs_dir}/${shortened_channel_name}" echo "${login_user}":'{PLAIN}'"${login_pw}" > "${irclogs_pw_dir}/${shortened_channel_name}" - # If "gpg" line, encrypt old raw logs to that GPG key. + # If "gpg_key" line, encrypt old raw logs to that GPG key. elif [ "${first_word}" = "gpg_key" ]; then key=$(echo -n "${line}" | cut -d' ' -f2) mkdir -p ~/plomlombot_db diff --git a/buster/setup_scripts/mirror_dir.sh b/buster/setup_scripts/mirror_dir.sh new file mode 100755 index 0000000..0fc03aa --- /dev/null +++ b/buster/setup_scripts/mirror_dir.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Mirror directory tree from remote to local server, keeping the path. +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}" "${path_package}" +mkdir -p "${dir}" +cd "${dir}" +tar xf "${path_package}" +cd +rm "${path_package}" +ssh plom@"${server}" rm "${path_package}" diff --git a/buster/setup_scripts/setup_website.sh b/buster/setup_scripts/setup_website.sh index 2eabead..fef4b67 100755 --- a/buster/setup_scripts/setup_website.sh +++ b/buster/setup_scripts/setup_website.sh @@ -84,6 +84,13 @@ chown plom:plom /home/plom/.plomlombot systemctl enable plomlombot.service service plomlombot start +# Migrate borg repo. +cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/ +su -lc "./mirror_dir.sh ${old_server} /home/plom/borg" plom + +# Clean up +rm /home/plom/{prepare_to_meet_server,mirror_dir}.sh + # TODO: # - commit git-daemon-export-ok directly into the public repos; rename # /home/plom/public_repos to /home/plom/repos