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