Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
c6f1b962
Commit
c6f1b962
authored
13 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
LMS-2471 new snapshot creation script
SVN: 22578
parent
259ed94d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis_all/source/bash/create-snapshot.sh
+122
-0
122 additions, 0 deletions
openbis_all/source/bash/create-snapshot.sh
with
122 additions
and
0 deletions
openbis_all/source/bash/create-snapshot.sh
0 → 100755
+
122
−
0
View file @
c6f1b962
#! /bin/bash
#
# Creates a snapshot of an openBIS instance based on a configuration file.
#
# usage: create-snapshot.sh <configuration file>
#
# The configuration files knows the following key-value pairs (stored as <key> = <value>):
#
# repository Path to the directory which will store the snapshot.
# servers Path to to a directory which contains the folders 'datastore_server'
# and 'openBIS-server'.
# store Path to the directory which contains the data set store. Everything there
# will be added to the snapshot.
# databases Space separated list of database to be dumped.
# index Relative path to the lucene index.
# It is relative to <servers path>/openBIS-server/jetty/.
# If this optional attribute is missing no lucene index will added to the snapshot.
#
# Important Notes:
# - This script should be run after all servers have been stopped.
# - Can not be used for segmented stores because the script doesn't follow symbolic links.
#
function
getValue
{
file
=
$1
key
=
$2
awk
-F
' *= *'
-v
key
=
$2
'{map[$1] = $2} END {print map[key]}'
$file
}
if
[
$#
-ne
1
]
;
then
echo
"Usage: create-snapshot.sh <configuration file>"
exit
1
fi
CONFIGURATION_FILE
=
"
$1
"
SERVERS_PATH
=
`
getValue
$CONFIGURATION_FILE
servers
`
if
[
-z
"
$SERVERS_PATH
"
]
;
then
echo
"Path to servers not specified in
$CONFIGURATION_FILE
."
exit
1
fi
OPENBIS_AS_ROOT
=
"
$SERVERS_PATH
/openBIS-server/jetty/"
if
[
!
-d
"
$OPENBIS_AS_ROOT
"
]
;
then
echo
"Error:
$OPENBIS_AS_ROOT
isn't a directory."
echo
"Most probable reason:
$SERVERS_PATH
doesn't point to a valid openBIS instance."
exit
1
fi
REPOSITORY
=
`
getValue
$CONFIGURATION_FILE
repository
`
if
[
-z
"
$REPOSITORY
"
]
;
then
echo
"Repository not specified in
$CONFIGURATION_FILE
."
exit
1
fi
mkdir
-p
"
$REPOSITORY
"
STORE
=
`
getValue
$CONFIGURATION_FILE
store
`
if
[
-z
"
$STORE
"
]
;
then
echo
"Store not specified in
$CONFIGURATION_FILE
."
exit
1
fi
if
[
!
-d
"
$STORE
"
]
;
then
echo
"Store path
$STORE
doesn't point to an existing directory."
exit
1
fi
DATABASES
=
`
getValue
$CONFIGURATION_FILE
databases
`
if
[
-z
"
$DATABASES
"
]
;
then
echo
"At least one database has to be specified in
$CONFIGURATION_FILE
."
exit
1
fi
INDEX
=
`
getValue
$CONFIGURATION_FILE
index
`
if
[
-n
"
$INDEX
"
]
;
then
if
[
!
-d
"
$INDEX
"
]
;
then
mkdir
-p
"
$INDEX
"
fi
fi
TIMESTAMP
=
`
date
+%Y-%m-%d_%H:%M:%S
`
SNAPSHOT_FOLDER
=
"openbis-snapshot-
$TIMESTAMP
"
SNAPSHOT
=
"
$REPOSITORY
/
$SNAPSHOT_FOLDER
"
##################################################
#
# Starting snapshot creation
#
echo
"==== creating snapshot
$SNAPSHOT
.tgz"
mkdir
"
$SNAPSHOT
"
cp
-p
"
$CONFIGURATION_FILE
"
"
$SNAPSHOT
"
############## dump the store ##############
tar
-cf
"
$SNAPSHOT
/store.tar"
-C
"
$STORE
"
.
if
[
$?
-ne
0
]
;
then
echo
"Error creating store dump. Snapshot creation aborted."
exit
1
fi
echo
"Dump of store
$STORE
has been successfully created."
############## dump databases ##############
for
db
in
$DATABASES
;
do
pg_dump
-U
postgres
-O
$db
>
"
$SNAPSHOT
/
$db
.sql"
if
[
$?
-ne
0
]
;
then
echo
"Error dumping database '
$db
'. Snapshot creation aborted."
exit
1
fi
echo
"Database '
$db
' has been successfully dumped."
done
############## dump index (if requested) ##############
if
[
-n
"
$INDEX
"
]
;
then
tar
-cf
"
$SNAPSHOT
/index.tar"
-C
"
$INDEX
"
.
if
[
$?
-ne
0
]
;
then
echo
"Error creating index dump. Snapshot creation aborted."
exit
1
fi
echo
"Dump of index
$INDEX
has been successfully created."
fi
############## packaging ##############
tar
-zcf
"
$SNAPSHOT
.tgz"
-C
"
$REPOSITORY
"
"
$SNAPSHOT_FOLDER
"
if
[
$?
-ne
0
]
;
then
echo
"Error packaging snapshot
$SNAPSHOT
."
exit
1
fi
rm
-rf
"
$SNAPSHOT
"
echo
"====
$SNAPSHOT
.tgz successfully created."
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