X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=buster%2Fsetup_scripts%2Fmigrate_app.sh;h=6e18f330e89eb5febf4c69302997a768fb13f33f;hb=f1901562e5d3859b4e9a9eb7c5f48c6db73fc8b1;hp=c0e1637c699e7db769077e5877273d0f6aaf5b94;hpb=19bd8ce75275c6d6d737dbdf78ab3d969369b19f;p=config diff --git a/buster/setup_scripts/migrate_app.sh b/buster/setup_scripts/migrate_app.sh index c0e1637..6e18f33 100755 --- a/buster/setup_scripts/migrate_app.sh +++ b/buster/setup_scripts/migrate_app.sh @@ -2,18 +2,26 @@ set -e set -x -if [ "$#" -lt 4 ]; then - echo 'Need at least four arguments: old server IP, service name, DB name, and backup directory names.' +if [ "$#" -lt 2 ]; then + echo 'Need two arguments: old server IP, and service name.' false fi -if [ ! "$1" = "pleroma" ] && [ ! "$1" = "peertube" ]; then - echo "Need legal service name (pleroma or peertube)." +if [ ! "$2" = "pleroma_otp" ] && [ ! "$2" = "pleroma_source" ] && [ ! "$2" = "peertube" ]; then + echo "Need legal service name (pleroma_otp or pleroma_source or peertube)." false fi server_ip="$1" app="$2" -db_name="$3" -shift 3 +if [ "${app}" = "pleroma_otp" ]; then + db_name="pleroma" + dirs="/var/lib/pleroma/uploads /etc/pleroma" +if [ "${app}" = "pleroma_source" ]; then + db_name="pleroma" + dirs="/var/lib/pleroma/uploads /opt/pleroma/config" +elif [ "${app}" = "peertube" ]; then + db_name="peertube_prod" + dirs="/var/www/peertube/storage /var/www/peertube/config" +fi config_tree_prefix="${HOME}/config/buster" setup_scripts_dir="${config_tree_prefix}/setup_scripts" @@ -23,6 +31,6 @@ cd "${setup_scripts_dir}" read -p'Hit Enter when you are done.' ignore eval $(ssh-agent) && ssh-add echo 'Enter password for root on target server next.' -ssh plom@"${server_ip}" 'su -lc "cd config/buster/setup_scripts && git pull && ./backup_${app}.sh ${app} ${db_name} $@"' +ssh plom@"${server_ip}" "su -lc \"cd config/buster/setup_scripts && git pull && ./backup_app.sh ${app} ${db_name} ${dirs}\"" scp plom@"${server_ip}":~/${app}_backup.tar /home/plom/${app}_backup.tar -./restore_${app}.sh +./restore_app.sh "${app}" "${db_name}"