Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resifInv
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSUG
RESIF
resifInv
Merge requests
!4
[restore] indentations
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
[restore] indentations
restore2
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Jonathan Schaeffer
requested to merge
restore2
into
master
4 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
e4761795
1 commit,
4 years ago
1 file
+
19
−
20
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
admin/pgsql_restore_resifinv.sh
+
19
−
20
Options
@@ -32,35 +32,34 @@ function report_to_zabbix(){
}
function
hook_script
(){
psql
--host
$host
-p
5432
-U
$user
-d
$dbpreprod
-f
$1
if
[[
$?
-eq
0
]]
;
then
report_to_zabbix
"OK"
else
report_to_zabbix
"Error on hook script
$1
"
fi
psql
--host
$host
-p
5432
-U
$user
-d
$dbpreprod
-f
$1
if
[[
$?
-eq
0
]]
;
then
report_to_zabbix
"OK"
else
report_to_zabbix
"Error on hook script
$1
"
return
1
fi
}
function
database_restore
()
{
#
o
n récupere le dump qui a moins de 24 heures
#
O
n récupere le dump qui a moins de 24 heures
DUMPFILE
=
$(
find
$DUMPDIR
-name
$1
.dump
-mtime
-1
|
tail
-1
)
[[
-f
$DUMPFILE
]]
||
{
echo
$1
.dump does not exist
report_to_zabbix
"failed:
$1
.dump not found in
$DUMPDIR
"
return
1
}
echo
pg_restore
--no-owner
--clean
--no-password
--host
=
$host
-U
postgres
--dbname
=
$2
$DUMPFILE
pg_restore
--no-owner
--clean
--no-password
--host
=
$host
-U
postgres
--dbname
=
$2
$DUMPFILE
report_to_zabbix
"failed:
$1
.dump not found in
$DUMPDIR
"
return
1
}
echo
pg_restore
--no-owner
--clean
--no-password
--host
=
localhost
-U
postgres
--dbname
=
$2
$DUMPFILE
pg_restore
--no-owner
--clean
--no-password
--host
=
localhost
-U
postgres
--dbname
=
$2
$DUMPFILE
code
=
$?
if
[
$code
-ne
0
]
;
then
echo
1>&2
"Restore failed"
finlog
=
$(
tail
-1
$LOG
)
report_to_zabbix
"
$finlog
"
else
hook_script
$LOCALDIR
/../SQL/resifinv-views.sql
hook_script
$LOCALDIR
/../SQL/resifinv-views.sql
hook_script
$LOCALDIR
/../SQL/operator.sql
report_to_zabbix
"Error restoring database: pg_restore --no-owner --clean --no-password --host=localhost -U postgres --dbname=
$2
$DUMPFILE
"
fi
hook_script
$LOCALDIR
/../SQL/resifinv-views.sql
||
exit
1
hook_script
$LOCALDIR
/../SQL/resifinv-foreign.sql
||
exit
1
hook_script
$LOCALDIR
/../SQL/operator.sql
||
exit
1
}
database_restore
$dbprod
$dbpreprod
report_to_zabbix
"OK:
$dbpreprod
Restored"
Loading