Verified Commit 1c4a9172 authored by Loïc Dachary's avatar Loïc Dachary
Browse files

rezo-import: re-use an existing instance

parent 29f6e98b
#!/bin/bash
DISCOURSE_VERSION=v2.7.8
if test -f mailman2discourse/$DISCOURSE_VERSION/apipassword ; then
API_PASSWORD=$(cat mailman2discourse/$DISCOURSE_VERSION/apipassword)
fi
function discourse_setting() {
local base="$1"
......@@ -48,12 +51,26 @@ function download() {
done
}
function upload() {
function download_info() {
rsync -av $RSYNC_USER@porter2.octopuce.fr:/srv/discourse_docker/apikey/$ORG mailman2discourse/$DISCOURSE_VERSION/apikey
rsync -av $RSYNC_USER@porter2.octopuce.fr:/srv/orgs/$ORG/api mailman2discourse/$DISCOURSE_VERSION/apipassword
API_PASSWORD=$(cat mailman2discourse/$DISCOURSE_VERSION/apipassword)
}
function download_backup() {
local d=mailman2discourse/$DISCOURSE_VERSION/shared/standalone/backups/default
rsync -av --progress $RSYNC_USER@porter2.octopuce.fr:/srv/discourse/shared/standalone/backups/$ORG/ $d/
}
function upload_backup() {
local d=mailman2discourse/$DISCOURSE_VERSION/shared/standalone/backups/default
ssh $RSYNC_USER@porter2.octopuce.fr mkdir -p /tmp/$ORG
rsync -av --progress $d/*.tar.gz $RSYNC_USER@porter2.octopuce.fr:/tmp/$ORG/
ssh -t $RSYNC_USER@porter2.octopuce.fr sudo mkdir /srv/discourse/shared/standalone/backups/$ORG
ssh -t $RSYNC_USER@porter2.octopuce.fr sudo mv /tmp/$ORG/* /srv/discourse/shared/standalone/backups/$ORG/
}
function upload_info() {
rsync -av --ignore-existing mailman2discourse/$DISCOURSE_VERSION/apikey $RSYNC_USER@porter2.octopuce.fr:/srv/discourse_docker/apikey/$ORG
}
......@@ -127,6 +144,29 @@ function backup() {
echo $d/*.tar.gz
}
function restore() {
local d=mailman2discourse/$DISCOURSE_VERSION/shared/standalone/backups/default
local backup=$(find $d/*.tar.gz | sort | tail -1)
backup=$(basename $backup)
if test -z "$backup" -o "$backup" = "*.tar.gz" ; then
echo no backup to restore
return
fi
docker exec -ti app$DISCOURSE_VERSION discourse enable_restore
docker exec -ti app$DISCOURSE_VERSION discourse restore $backup
docker exec -ti app$DISCOURSE_VERSION discourse disable_restore
discourse_setting admin/site_settings force_https false
}
#
# Build from scratch
#
# download repickle reset_discourse setup_hosts create_admin site_settings run_mailman2discourse ban_emails mbox obfuscate_emails backup upload_backup upload_info
#
# Reuse an existing discourse
#
# download repickle reset_discourse setup_hosts download_backup download_info restore run_mailman2discourse mbox obfuscate_emails backup upload_backup
#
for f in ${@:-download repickle reset_discourse setup_hosts create_admin site_settings run_mailman2discourse ban_emails mbox obfuscate_emails backup upload} ; do
$f || break
done
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment