home · contact · privacy
Extend Pleroma-from-source scripting.
[config] / buster / setup_scripts / migrate_app.sh
1 #!/bin/sh
2 set -e
3 set -x
4
5 if [ "$#" -lt 2 ]; then
6     echo 'Need two arguments: old server IP, and service name.'
7     false
8 fi
9 if [ ! "$2" = "pleroma_otp" ] && [ ! "$2" = "pleroma_source" ] && [ ! "$2" = "peertube" ]; then
10     echo "Need legal service name (pleroma_otp or pleroma_source or peertube)."
11     false
12 fi
13 server_ip="$1"
14 app="$2"
15 if [ "${app}" = "pleroma_otp" ]; then
16     db_name="pleroma"
17     dirs="/var/lib/pleroma/uploads /etc/pleroma"
18 if [ "${app}" = "pleroma_source" ]; then
19     db_name="pleroma"
20     dirs="/var/lib/pleroma/uploads /opt/pleroma/config"
21 elif [ "${app}" = "peertube" ]; then
22     db_name="peertube_prod"
23     dirs="/var/www/peertube/storage /var/www/peertube/config"
24 fi
25
26 config_tree_prefix="${HOME}/config/buster"
27 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
28
29 cd "${setup_scripts_dir}"
30 ./prepare_to_meet_server.sh "${server_ip}"
31 read -p'Hit Enter when you are done.' ignore
32 eval $(ssh-agent) && ssh-add
33 echo 'Enter password for root on target server next.'
34 ssh plom@"${server_ip}" "su -lc \"cd config/buster/setup_scripts && git pull && ./backup_app.sh ${app} ${db_name} ${dirs}\""
35 scp plom@"${server_ip}":~/${app}_backup.tar /home/plom/${app}_backup.tar
36 ./restore_app.sh "${app}" "${db_name}"