Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armand Sady
SCODOC_R6A06
Commits
64c72764
Commit
64c72764
authored
3 years ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
fix migration script
parent
f63616c6
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+4
-3
4 additions, 3 deletions
README.md
tools/debian/postinst
+12
-9
12 additions, 9 deletions
tools/debian/postinst
tools/migrate_from_scodoc7.sh
+15
-9
15 additions, 9 deletions
tools/migrate_from_scodoc7.sh
tools/save_scodoc7_data.sh
+0
-70
0 additions, 70 deletions
tools/save_scodoc7_data.sh
with
31 additions
and
91 deletions
README.md
+
4
−
3
View file @
64c72764
...
...
@@ -70,13 +70,14 @@ Principaux contenus:
Installer ScoDoc 9 normalement (
[
voir la doc
](
https://scodoc.org/GuideInstallDebian11
)
).
Puis remplacer
`/o
t
p/scodoc`
par un clone du git.
Puis remplacer
`/op
t
/scodoc`
par un clone du git.
sudo su
mv /opt/scodoc /opt/scodoc-distrib # ou ce que vous voulez
apt-get install git # si besoin
cd /opt
git clone https://scodoc.org/git/viennet/ScoDoc.git
# (ou bien utiliser votre clone gitea s
o
vous l'avez déjà créé !)
# (ou bien utiliser votre clone gitea s
i
vous l'avez déjà créé !)
mv ScoDoc scodoc # important !
cd /opt/scodoc
# 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:
export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV
"
export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV
puis de les lancer normalement, par exemple:
...
...
This diff is collapsed.
Click to expand it.
tools/debian/postinst
+
12
−
9
View file @
64c72764
...
...
@@ -18,15 +18,18 @@ change_scodoc_file_ownership
# --- Création au bseoin de /opt/scodoc-data
set_scodoc_var_dir
# ------------ LOCALES (pour compat bad ScoDoc 7)
locname
=
"en_US.UTF-8"
# ------------ LOCALES (pour compat bases ScoDoc 7 et plus anciennes)
for
locname
in
"en_US.UTF-8"
do
outname
=
$(
echo
${
locname
//-/
}
|
tr
'[A-Z]'
'[a-z]'
)
if
[
"
$(
locale
-a
|
grep
-E
-i
^
${
outname
}
$
|
wc
-l
)
"
-lt
1
]
then
echo
adding
$locname
echo
"
$locname
${
locname
##*.
}
"
>>
/etc/locale.gen
/usr/sbin/locale-gen
--keep-existing
systemctl restart postgresql
fi
done
# 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) }'
)
...
...
This diff is collapsed.
Click to expand it.
tools/migrate_from_scodoc7.sh
+
15
−
9
View file @
64c72764
...
...
@@ -10,8 +10,6 @@
#
#
set
-euo
pipefail
# Le répertoire de ce script:
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
"
# 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
()
{
...
...
@@ -71,12 +69,19 @@ fi
# Inutile si on importe via pg_restore (voir restore-scodoc7_data.sh)
#
migrate_database_ownership
()
{
echo
"Changing databases ownerships"
SCO7_BASES
=
$(
su
-c
"psql -l -t | grep www-data"
"
$POSTGRES_SUPERUSER
"
|
awk
-F
'|'
'{print $1}'
)
if
[
-z
"
$SCO7_BASES
"
]
then
echo
"Aucune base ScoDoc 7 appartenant à www-data. OK."
else
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
...
...
@@ -99,7 +104,8 @@ migrate_local_files() {
fi
mkdir
"
$SCODOC_VAR_DIR
"
||
die
"erreur creation repertoire"
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
old_logs_dest="
$SCODOC_VAR_DIR
/log/scodoc7
"
echo "
Copie des anciens logs ScoDoc 7 dans
$old_logs_dest
"
...
...
This diff is collapsed.
Click to expand it.
tools/save_scodoc7_data.sh
deleted
100755 → 0
+
0
−
70
View file @
f63616c6
#!/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
\n
Please check that SQL server is running
\n
Aborting.
\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)."
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment