Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4a834d748f | |||
48d5995a2a | |||
529b01353a |
84
config/save_scodoc7_data.sh
Executable file
84
config/save_scodoc7_data.sh
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# ScoDoc: save all user data (database, configs, images, archives...) in separate directory
|
||||
#
|
||||
# Utile pour migrer les données ScoDoc 7 vers ScoDoc 9
|
||||
# Executer en tant que root sur le serveur d'origine
|
||||
#
|
||||
# E. Viennet, Sept 2011, Aug 2020, Aug 21
|
||||
#
|
||||
source utils.sh
|
||||
|
||||
# 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
|
||||
|
||||
INSTANCE_DIR=/opt/scodoc
|
||||
SCODOC_DIR="$INSTANCE_DIR/Products/ScoDoc"
|
||||
|
||||
source utils.sh
|
||||
check_uid_root "$0"
|
||||
|
||||
echo "Stopping ScoDoc..."
|
||||
scodocctl stop
|
||||
|
||||
# Dump all postgres databases
|
||||
|
||||
echo "Dumping SQL databases..."
|
||||
chown postgres "$DEST"
|
||||
for cfgfile in "$INSTANCE_DIR"/var/scodoc/config/depts/*cfg USERS
|
||||
do
|
||||
cfgfile=$(basename "$cfgfile")
|
||||
dept="${cfgfile%*.cfg}"
|
||||
db_name=$(echo "SCO$dept" | tr "[:lower:]" "[:upper:]")
|
||||
echo "$db_name"
|
||||
su -c "pg_dump --format=custom --file=\"$DEST/$db_name.dump\" \"$db_name\"" postgres
|
||||
if [ ! "$?" -eq 0 ]
|
||||
then
|
||||
printf "Error dumping postgresql database\nPlease check that SQL server is running\nAborting."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
chown root "$DEST"
|
||||
|
||||
# Zope DB, ScoDoc archives, configuration, photos, etc.
|
||||
echo "Copying var/ ..."
|
||||
cp -rp "$INSTANCE_DIR/var" "$DEST"
|
||||
|
||||
echo "Copying logos..."
|
||||
cp -rp "$SCODOC_DIR/logos" "$DEST"
|
||||
|
||||
echo "Copying configuration file..."
|
||||
mkdir "$DEST/config"
|
||||
cp -p "$SCODOC_DIR/config/scodoc_config.py" "$DEST/config/"
|
||||
cp -rp "$SCODOC_DIR/config/doc_poursuites_etudes" "$DEST/config/"
|
||||
|
||||
echo "Copying server logs..."
|
||||
cp -rp "$INSTANCE_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)."
|
@ -10,6 +10,19 @@
|
||||
#
|
||||
source utils.sh
|
||||
|
||||
echo "Ce script est utile pour transférer les données d'un serveur ScoDoc 7"
|
||||
echo "à un autre ScoDoc 7."
|
||||
echo "NE PAS L'UTILISER POUR PASSER A UN SERVEUR ScoDoc 9 !"
|
||||
echo "Pour cela, utiliser save_scodoc7_data.sh"
|
||||
echo
|
||||
echo -n "Voulez-vous poursuivre cette operation ? (y/n) [n]"
|
||||
read -r ans
|
||||
if [ ! "$(norm_ans "$ans")" = 'Y' ]
|
||||
then
|
||||
echo "Annulation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Destination directory
|
||||
if [ ! $# -eq 1 ]
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user