From: Christian Heller Date: Sun, 26 Jan 2020 21:40:15 +0000 (+0100) Subject: Pleroma migration scripts. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/new_day?a=commitdiff_plain;h=19172909051f0465122c497581a44237d1129a0e;p=config Pleroma migration scripts. --- diff --git a/buster/setup_scripts/backup_pleroma.sh b/buster/setup_scripts/backup_pleroma.sh index ae1e6bd..ae95b4d 100755 --- a/buster/setup_scripts/backup_pleroma.sh +++ b/buster/setup_scripts/backup_pleroma.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x # Heavily inspired by service pleroma stop diff --git a/buster/setup_scripts/migrate_pleroma.sh b/buster/setup_scripts/migrate_pleroma.sh new file mode 100755 index 0000000..bff9872 --- /dev/null +++ b/buster/setup_scripts/migrate_pleroma.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e +set -x +# Heavily inspired by + +if [ "$#" -ne 1 ]; then + echo 'Need server IP as argument.' + false +fi +server_ip="$1" + +config_tree_prefix="${HOME}/config/buster" +setup_scripts_dir="${config_tree_prefix}/setup_scripts" +cd "${setup_scripts_dir}" +./prepare_to_meet_server.sh "${server_ip}" +read -p'Hit Enter when you are done.' ignore +ssh plom@"${server_ip}" 'su -lc "cd config && git pull"' +ssh plom@"${server_ip}" 'su -lc "cd config/buster/setup_scripts && ./backup_pleroma.sh"' +scp plom@"${server_ip}":~/pleroma_backup.tar /home/plom/pleroma_backup.tar +./backup_pleroma.sh diff --git a/buster/setup_scripts/prepare_to_meet_server.sh b/buster/setup_scripts/prepare_to_meet_server.sh new file mode 100755 index 0000000..569bf74 --- /dev/null +++ b/buster/setup_scripts/prepare_to_meet_server.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Do some of the steps necessary to SSH (key-based) with another server. +set -e + +if [ "$#" -ne 1 ]; then + echo 'Need server IP as argument.' + false +fi +target="$1" + +# We need a public key to copy over, so generate it if not found. +if [ ! -f ~/.ssh/id_rsa.pub ]; then + ssh-keygen +fi + +# Add target to ~/.ssh/known_hosts so we don't get +# asked for permission at inopportune moments. +ssh-keyscan -H "$target" >> ~/.ssh/known_hosts + +# Tell user what to do. +echo "APPEND FOLLOWING TO TARGET'S ~/.ssh/authorized_keys:" +cat ~/.ssh/id_rsa.pub diff --git a/buster/setup_scripts/restore_pleroma.sh b/buster/setup_scripts/restore_pleroma.sh index 4f4d05b..844a655 100755 --- a/buster/setup_scripts/restore_pleroma.sh +++ b/buster/setup_scripts/restore_pleroma.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +set -x # Heavily inspired by service pleroma stop