home · contact · privacy
Fix.
[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 service="$2"
16 if [ "${app}" = "pleroma_otp" ]; then
17     db_name="pleroma"
18     dirs="/var/lib/pleroma/uploads /etc/pleroma"
19     service=pleroma
20 elif [ "${app}" = "pleroma_source" ]; then
21     db_name="pleroma"
22     dirs="/var/lib/pleroma/uploads /opt/pleroma/config"
23     service=pleroma
24 elif [ "${app}" = "peertube" ]; then
25     db_name="peertube_prod"
26     dirs="/var/www/peertube/storage /var/www/peertube/config"
27 fi
28
29 config_tree_prefix="${HOME}/config/buster"
30 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
31
32 cd "${setup_scripts_dir}"
33 ./prepare_to_meet_server.sh "${server_ip}"
34 read -p'Hit Enter when you are done.' ignore
35 eval $(ssh-agent) && ssh-add
36 echo 'Enter password for root on target server next.'
37 ssh plom@"${server_ip}" "su -lc \"cd config/buster/setup_scripts && git pull && ./backup_app.sh ${service} ${db_name} ${dirs}\""
38 scp plom@"${server_ip}":~/${app}_backup.tar /home/plom/${app}_backup.tar
39 ./restore_app.sh "${app}" "${db_name}"