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
4b2d5f01
Commit
4b2d5f01
authored
3 years ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
backup scripts for ScoDoc 9
parent
a6b97e96
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tools/backups/backup_db9
+9
-10
9 additions, 10 deletions
tools/backups/backup_db9
tools/backups/backup_rotation.sh
+1
-1
1 addition, 1 deletion
tools/backups/backup_rotation.sh
tools/backups/backup_to_remote_server.sh
+9
-9
9 additions, 9 deletions
tools/backups/backup_to_remote_server.sh
with
19 additions
and
20 deletions
misc
/backup_db
2
→
tools/backups
/backup_db
9
+
9
−
10
View file @
4b2d5f01
#!/bin/bash
#!/bin/bash
# usage: backup_db
2
dbname
# usage: backup_db
9
dbname
# Dump une base postgresql, et garde plusieurs dumps dans le passe
# Dump une base postgresql, et garde plusieurs dumps dans le passe
# (configurable dans le script backup_rotation.sh)
# (configurable dans le script backup_rotation.sh)
# Les dumps sont compresses (gzip).
# Les dumps sont compresses (gzip).
#
#
# E. Viennet pour ScoDoc, 2014
# E. Viennet pour ScoDoc, 2014
, 2021 pour ScoDoc 9
# (ce script est meilleur que l'ancien backup-db, car l'espace entre
# (ce script est meilleur que l'ancien backup-db, car l'espace entre
# deux sauvegardes dépend de leur anciennete)
# deux sauvegardes dépend de leur anciennete)
#
#
#
#
# Note: pour restaurer un backup (en supprimant la base existante !):
# Note: pour restaurer un backup (en supprimant la base existante !):
#
#
# 0- Arreter scodoc:
/etc/init.d/scodoc stop (ou
systemctl stop scodoc
)
# 0- Arreter scodoc: systemctl stop scodoc
#
#
# Puis en tant qu'utilisateur
postgres: su postgres
# Puis en tant qu'utilisateur
scodoc: su scodoc
# 1- supprimer la base existante si elle existe: dropdb SCO
XXX
# 1- supprimer la base existante si elle existe: dropdb SCO
DOC
#
#
# 2- recreer la base, vide: createdb -E UTF-8 SCOXXX
# 2- recreer la base, vide: createdb -E UTF-8 SCOXXX
# (nom de la base: SCOXXX ou XXX=departement)
# /opt/scodoc/tools/create_database.sh SCODOC
#
# 3- pg_restore -d SCODOC SCODOC_pgdump
# 3- pg_restore -d SCOXXX SCOXXX_pgdump
#
#
# Revenir a l'utilisateur root: exit
# Revenir a l'utilisateur root: exit
# 4- Relancer scodoc:
/etc/init.d/scodoc start (ou
systemctl start scodoc
)
# 4- Relancer scodoc: systemctl start scodoc
DBNAME
=
$1
DBNAME
=
$1
DUMPBASE
=
"
$DBNAME
"
-BACKUPS
DUMPBASE
=
"
$DBNAME
"
-BACKUPS
...
@@ -50,4 +49,4 @@ pg_dump --format=t "$DBNAME" -f $DUMPFILE
...
@@ -50,4 +49,4 @@ pg_dump --format=t "$DBNAME" -f $DUMPFILE
gzip
$DUMPFILE
gzip
$DUMPFILE
# 3- Rotate backups: remove unneeded copies
# 3- Rotate backups: remove unneeded copies
/opt/scodoc/
Products/ScoDoc/misc
/backup_rotation.sh
"
$DUMPBASE
"
/opt/scodoc/
tools/backups
/backup_rotation.sh
"
$DUMPBASE
"
This diff is collapsed.
Click to expand it.
misc
/backup_rotation.sh
→
tools/backups
/backup_rotation.sh
+
1
−
1
View file @
4b2d5f01
#!/bin/bash
#!/bin/bash
# Backup rotation
# Backup rotation
# Usage example: backup_rotation.sh /var/lib/postgresql/BACKUP-SCO
GEII
# Usage example: backup_rotation.sh /var/lib/postgresql/BACKUP-SCO
DOC
#
#
# This script is designed to run each hour
# This script is designed to run each hour
#
#
...
...
This diff is collapsed.
Click to expand it.
misc
/backup_to_remote_server.sh
→
tools/backups
/backup_to_remote_server.sh
+
9
−
9
View file @
4b2d5f01
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# A adapter a vos besoins. Utilisation a vos risques et perils.
# A adapter a vos besoins. Utilisation a vos risques et perils.
#
#
# E. Viennet, 2002
# E. Viennet, 2002
, 2021
# Installation:
# Installation:
# 1- Installer rsync:
# 1- Installer rsync:
...
@@ -30,8 +30,8 @@ logfile=/var/log/rsynclog # log sur serveur scodoc
...
@@ -30,8 +30,8 @@ logfile=/var/log/rsynclog # log sur serveur scodoc
# A qui envoyer un mail en cas d'erreur de la sauvegarde:
# A qui envoyer un mail en cas d'erreur de la sauvegarde:
SUPERVISORMAIL
=
emmanuel.viennet@example.com
SUPERVISORMAIL
=
emmanuel.viennet@example.com
CALLER
=
`
basename
$0
`
CALLER
=
$(
basename
$0
)
MACHINE
=
`
hostname
-s
`
MACHINE
=
$(
hostname
-s
)
# -----------------------------------------------------
# -----------------------------------------------------
...
@@ -40,7 +40,7 @@ MACHINE=`hostname -s`
...
@@ -40,7 +40,7 @@ MACHINE=`hostname -s`
# ----------------------------------
# ----------------------------------
terminate
()
terminate
()
{
{
dateTest
=
`
date
`
dateTest
=
$(
date
)
mail
-s
"Attention: Probleme sauvegarde ScoDoc"
$SUPERVISORMAIL
<<
EOF
mail
-s
"Attention: Probleme sauvegarde ScoDoc"
$SUPERVISORMAIL
<<
EOF
The execution of script
$CALLER
was not successful on
$MACHINE
.
The execution of script
$CALLER
was not successful on
$MACHINE
.
...
@@ -57,7 +57,7 @@ EOF
...
@@ -57,7 +57,7 @@ EOF
echo
"Look at logfile
$logfile
"
echo
"Look at logfile
$logfile
"
echo
echo
echo
"
$CALLER
terminated, exiting now with rc=1."
echo
"
$CALLER
terminated, exiting now with rc=1."
dateTest
=
`
date
`
dateTest
=
$(
date
)
echo
"End of script at:
$dateTest
"
echo
"End of script at:
$dateTest
"
echo
""
echo
""
...
@@ -74,16 +74,16 @@ EOF
...
@@ -74,16 +74,16 @@ EOF
# --------------------------------------
# --------------------------------------
rsync_mirror_to_remote
()
rsync_mirror_to_remote
()
{
{
echo
"--------------- mirroring
"
$MACHINE
:
$srcdir
"
to
"
$remotehost
:
$destdir
>>
$logfile
2>&1
echo
"--------------- mirroring
$MACHINE
:
$srcdir
to
$remotehost
:
$destdir
"
>>
$logfile
2>&1
echo
"starting at
"
`
date
`
>>
$logfile
2>&1
echo
"starting at
$(
date
)
"
>>
$logfile
2>&1
rsync
-vaze
ssh
--delete
--rsync-path
=
/usr/bin/rsync
$srcdir
$remotehost
":"
$destdir
>>
$logfile
2>&1
rsync
-vaze
ssh
--delete
--rsync-path
=
/usr/bin/rsync
"
$srcdir
"
"
$remotehost
:
$destdir
"
>>
$logfile
2>&1
if
[
$?
-ne
0
]
if
[
$?
-ne
0
]
then
then
echo
Error
in
rsync:
code
=
$?
echo
Error
in
rsync:
code
=
$?
terminate
terminate
fi
fi
echo
"ending at
"
`
date
`
>>
$logfile
2>&1
echo
"ending at
$(
date
)
"
>>
$logfile
2>&1
echo
"---------------"
>>
$logfile
2>&1
echo
"---------------"
>>
$logfile
2>&1
}
}
...
...
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