forked from ScoDoc/DocScoDoc
fix migration script
This commit is contained in:
parent
f63616c6b3
commit
64c72764b5
@ -70,13 +70,14 @@ Principaux contenus:
|
|||||||
|
|
||||||
Installer ScoDoc 9 normalement ([voir la doc](https://scodoc.org/GuideInstallDebian11)).
|
Installer ScoDoc 9 normalement ([voir la doc](https://scodoc.org/GuideInstallDebian11)).
|
||||||
|
|
||||||
Puis remplacer `/otp/scodoc` par un clone du git.
|
Puis remplacer `/opt/scodoc` par un clone du git.
|
||||||
|
|
||||||
sudo su
|
sudo su
|
||||||
mv /opt/scodoc /opt/scodoc-distrib # ou ce que vous voulez
|
mv /opt/scodoc /opt/scodoc-distrib # ou ce que vous voulez
|
||||||
|
apt-get install git # si besoin
|
||||||
cd /opt
|
cd /opt
|
||||||
git clone https://scodoc.org/git/viennet/ScoDoc.git
|
git clone https://scodoc.org/git/viennet/ScoDoc.git
|
||||||
# (ou bien utiliser votre clone gitea so vous l'avez déjà créé !)
|
# (ou bien utiliser votre clone gitea si vous l'avez déjà créé !)
|
||||||
mv ScoDoc scodoc # important !
|
mv ScoDoc scodoc # important !
|
||||||
cd /opt/scodoc
|
cd /opt/scodoc
|
||||||
# et voilà.
|
# et voilà.
|
||||||
@ -104,7 +105,7 @@ de données de développement dans un état connu, par exemple pour éviter de r
|
|||||||
|
|
||||||
Il suffit de positionner une variable d'environnement indiquant la BD utilisée par les tests:
|
Il suffit de positionner une variable d'environnement indiquant la BD utilisée par les tests:
|
||||||
|
|
||||||
export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV"
|
export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV
|
||||||
|
|
||||||
puis de les lancer normalement, par exemple:
|
puis de les lancer normalement, par exemple:
|
||||||
|
|
||||||
|
@ -18,15 +18,18 @@ change_scodoc_file_ownership
|
|||||||
# --- Création au bseoin de /opt/scodoc-data
|
# --- Création au bseoin de /opt/scodoc-data
|
||||||
set_scodoc_var_dir
|
set_scodoc_var_dir
|
||||||
|
|
||||||
# ------------ LOCALES (pour compat bad ScoDoc 7)
|
# ------------ LOCALES (pour compat bases ScoDoc 7 et plus anciennes)
|
||||||
locname="en_US.UTF-8"
|
for locname in "en_US.UTF-8"
|
||||||
outname=$(echo ${locname//-/} | tr '[A-Z]' '[a-z]')
|
do
|
||||||
if [ "$(locale -a | grep -E -i ^${outname}$ | wc -l)" -lt 1 ]
|
outname=$(echo ${locname//-/} | tr '[A-Z]' '[a-z]')
|
||||||
then
|
if [ "$(locale -a | grep -E -i ^${outname}$ | wc -l)" -lt 1 ]
|
||||||
echo adding $locname
|
then
|
||||||
echo "$locname ${locname##*.}" >> /etc/locale.gen
|
echo adding $locname
|
||||||
/usr/sbin/locale-gen --keep-existing
|
echo "$locname ${locname##*.}" >> /etc/locale.gen
|
||||||
fi
|
/usr/sbin/locale-gen --keep-existing
|
||||||
|
systemctl restart postgresql
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Le numero de version complet, genre 9.0.0
|
# Le numero de version complet, genre 9.0.0
|
||||||
SCODOC_RELEASE=$(grep SCOVERSION $SCODOC_DIR/sco_version.py | awk '{ print substr($3, 2, length($3)-2) }')
|
SCODOC_RELEASE=$(grep SCOVERSION $SCODOC_DIR/sco_version.py | awk '{ print substr($3, 2, length($3)-2) }')
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Le répertoire de ce script:
|
# Le répertoire de ce script:
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
@ -24,7 +22,7 @@ cd "$SCODOC_DIR" || die "ScoDoc 9 non installe"
|
|||||||
check_uid_root "$0"
|
check_uid_root "$0"
|
||||||
|
|
||||||
# ScoDoc 9 doit être bien installé
|
# ScoDoc 9 doit être bien installé
|
||||||
[ -e .env ] && die "ScoDoc 9 mal configuré: manque .env"
|
[ -e .env ] || die "ScoDoc 9 mal configuré: manque .env"
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
usage() {
|
usage() {
|
||||||
@ -71,12 +69,19 @@ fi
|
|||||||
# Inutile si on importe via pg_restore (voir restore-scodoc7_data.sh)
|
# Inutile si on importe via pg_restore (voir restore-scodoc7_data.sh)
|
||||||
#
|
#
|
||||||
migrate_database_ownership() {
|
migrate_database_ownership() {
|
||||||
|
echo "Changing databases ownerships"
|
||||||
SCO7_BASES=$(su -c "psql -l -t | grep www-data" "$POSTGRES_SUPERUSER" | awk -F '|' '{print $1}')
|
SCO7_BASES=$(su -c "psql -l -t | grep www-data" "$POSTGRES_SUPERUSER" | awk -F '|' '{print $1}')
|
||||||
for base in $SCO7_BASES
|
if [ -z "$SCO7_BASES" ]
|
||||||
do
|
then
|
||||||
su -c "psql -c 'REASSIGN OWNED BY \"www-data\" TO scodoc;' $base" "$POSTGRES_SUPERUSER"
|
echo "Aucune base ScoDoc 7 appartenant à www-data. OK."
|
||||||
done
|
else
|
||||||
su -c "psql -c 'REASSIGN OWNED BY \"www-data\" TO scodoc;'" "$POSTGRES_SUPERUSER"
|
for base in $SCO7_BASES
|
||||||
|
do
|
||||||
|
echo modifying $base owner
|
||||||
|
su -c "psql -c 'REASSIGN OWNED BY \"www-data\" TO scodoc;' $base" "$POSTGRES_SUPERUSER"
|
||||||
|
done
|
||||||
|
su -c "psql -c 'REASSIGN OWNED BY \"www-data\" TO scodoc;'" "$POSTGRES_SUPERUSER"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- 3. Fichiers locaux: /opt/scodoc7/var => /opt/scodoc-data
|
# --- 3. Fichiers locaux: /opt/scodoc7/var => /opt/scodoc-data
|
||||||
@ -99,7 +104,8 @@ migrate_local_files() {
|
|||||||
fi
|
fi
|
||||||
mkdir "$SCODOC_VAR_DIR" || die "erreur creation repertoire"
|
mkdir "$SCODOC_VAR_DIR" || die "erreur creation repertoire"
|
||||||
mv "${SCODOC7_HOME}"/var/scodoc/* "$SCODOC_VAR_DIR" || die "migrate_local_files failed"
|
mv "${SCODOC7_HOME}"/var/scodoc/* "$SCODOC_VAR_DIR" || die "migrate_local_files failed"
|
||||||
|
# mais récupère notre .env !
|
||||||
|
cp "$SCODOC_VAR_DIR_BACKUP"/.env "$SCODOC_VAR_DIR" || die "fichier .env manquant dans l'ancien "$SCODOC_VAR_DIR !"
|
||||||
# Anciens logs ScoDoc7
|
# Anciens logs ScoDoc7
|
||||||
old_logs_dest="$SCODOC_VAR_DIR/log/scodoc7"
|
old_logs_dest="$SCODOC_VAR_DIR/log/scodoc7"
|
||||||
echo "Copie des anciens logs ScoDoc 7 dans $old_logs_dest"
|
echo "Copie des anciens logs ScoDoc 7 dans $old_logs_dest"
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# ScoDoc: save all user data (database, configs, images, archives...) in separate directory
|
|
||||||
#
|
|
||||||
# Utile pour migrer ScoDoc d'un serveur a un autre
|
|
||||||
# Executer en tant que root sur le serveur d'origine
|
|
||||||
#
|
|
||||||
# E. Viennet, Sept 2011, Aug 2020, Jul 2021
|
|
||||||
#
|
|
||||||
# Le répertoire de ce script:
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
||||||
|
|
||||||
source "$SCRIPT_DIR/config.sh"
|
|
||||||
source "$SCRIPT_DIR/utils.sh"
|
|
||||||
|
|
||||||
|
|
||||||
check_uid_root "$0"
|
|
||||||
|
|
||||||
# Destination directory
|
|
||||||
if [ ! $# -eq 1 ]
|
|
||||||
then
|
|
||||||
echo "Usage: $0 destination_directory"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
DEST=$1
|
|
||||||
# remove trailing slashs if needed:
|
|
||||||
shopt -s extglob
|
|
||||||
DEST="${DEST%%+(/)}"
|
|
||||||
|
|
||||||
if [ ! -e "$DEST" ]
|
|
||||||
then
|
|
||||||
echo Creating directory "$DEST"
|
|
||||||
mkdir "$DEST"
|
|
||||||
else
|
|
||||||
echo "Error: Directory " "$DEST" " exists"
|
|
||||||
echo "remove it or specify another destination !"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Stopping ScoDoc..."
|
|
||||||
scodocctl stop
|
|
||||||
|
|
||||||
# Dump all postgres databases
|
|
||||||
echo "Dumping SQL database..."
|
|
||||||
chown postgres "$DEST"
|
|
||||||
su -c "pg_dumpall > \"$DEST\"/scodoc.dump.txt" postgres
|
|
||||||
if [ ! "$?" -eq 0 ]
|
|
||||||
then
|
|
||||||
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting.\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
chown root "$DEST"
|
|
||||||
|
|
||||||
# ScoDoc archives, configuration, photos, etc.
|
|
||||||
echo "Copying var/ ..."
|
|
||||||
cp -rp "$SCODOC_DIR/var" "$DEST"
|
|
||||||
|
|
||||||
|
|
||||||
echo "Copying server logs..."
|
|
||||||
cp -rp "$SCODOC_DIR/log" "$DEST"
|
|
||||||
|
|
||||||
|
|
||||||
# --- Archive all files in a tarball to ease transfer
|
|
||||||
echo
|
|
||||||
echo "Archiving backup files in a $DEST.tgz..."
|
|
||||||
base=$(basename "$DEST")
|
|
||||||
(cd "$DEST"/.. || terminate "directory error"; tar cfz "$DEST".tgz "$base")
|
|
||||||
|
|
||||||
echo "Done (you can copy " "$DEST"".tgz to destination machine)."
|
|
Loading…
Reference in New Issue
Block a user