Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iml-backup
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
IML Open Source
iml-backup
Commits
11220b73
Commit
11220b73
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update db plugins
parent
63490572
Branches
Branches containing commit
No related tags found
1 merge request
!129
Db Profiles
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/localdump/couchdb2.sh
+14
-30
14 additions, 30 deletions
plugins/localdump/couchdb2.sh
plugins/localdump/ldap.sh
+1
-1
1 addition, 1 deletion
plugins/localdump/ldap.sh
plugins/localdump/mysql.sh
+1
-1
1 addition, 1 deletion
plugins/localdump/mysql.sh
with
16 additions
and
32 deletions
plugins/localdump/couchdb2.sh
+
14
−
30
View file @
11220b73
...
...
@@ -82,14 +82,7 @@ function _getDblist(){
_couchapi GET _all_dbs |
sed
's#\"#\n#g'
|
grep
-Ev
"^(
\[
|
\,
|
\]
)$"
|
grep
-v
_replicator |
grep
-v
_global_changes
}
# UNUSED
# get value update_seq of given couchdb name
# function _getDbSeq(){
# # _couchapi GET $1 | sed 's#,\"#\n"#g' | egrep -v "^(\[|\,|\])$" | grep update_seq | cut -f 4 -d '"'
# _couchapi GET "$1" | sed 's#,\"#\n"#g' | grep -Ev "^(\[|\,|\])$" | grep update_seq | cut -f 4 -d '"' | cut -f 1 -d '-'
# }
# active curl prozesses
# get count of active curl prozesses
function
curlCount
(){
ps
-ef
|
grep
-v
grep
|
grep
"curl"
|
wc
-l
}
...
...
@@ -243,7 +236,7 @@ function _doBackupOfSingleInstance(){
# this is just a caching file of the sequence id of the last backup and can be safely deleted.
seqfile
=
"
${
ARCHIVE_DIR
}
/seq/all_seqids_of_last_backups_cache.txt"
echo
"---
$(
date
)
Get list of all databases"
echo
"---
$(
date
+%H:%M:%S
)
Get list of all databases"
_getDblist
>
"
${
dblistfile
}
"
typeset
-i
iDbTotal
;
iDbTotal
=
$(
wc
-l
<
"
$dblistfile
"
)
...
...
@@ -253,7 +246,7 @@ function _doBackupOfSingleInstance(){
# detect deleted databases:
echo
echo
"---
$(
date
)
MOVE deleted databases "
echo
"---
$(
date
+%H:%M:%S
)
MOVE deleted databases "
echo
"... into
${
ARCHIVE_DIR2
}
"
echo
for
dumpfile
in
$(
find
"
${
ARCHIVE_DIR
}
/"
-maxdepth
1
-type
f
-name
"*.couchdbdump.gz"
)
...
...
@@ -275,24 +268,25 @@ function _doBackupOfSingleInstance(){
done
echo
echo
"---
$(
date
)
DUMP databases"
echo
"---
$(
date
+%H:%M:%S
)
DUMP databases"
echo
" of instance
${
PROFILENAME
}
:
$iDbTotal
databases"
echo
" TO BACKUP
${
BACKUP_TARGETDIR
}
"
echo
" ARCHIVE
${
ARCHIVE_DIR
}
"
echo
echo
"-----
$(
date
)
- Get database meta infos ... max
$iParallel
parralel curl requests sending
$iChunksize
database urls per process"
echo
"-----
$(
date
+%H:%M:%S
)
- Get database meta infos ... max
$iParallel
parralel curl requests sending
$iChunksize
database urls per process"
seq
=
$(
reqCombined
$iChunksize
$iParallel
"
$dblistfile
"
| jq
-r
' [ .db_name, .update_seq ] | @csv '
|
tr
-d
'"'
|
tr
','
' '
|
awk
'{ sub(/-.*/, "", $2 ); print $1 "," $2 }'
)
# ^ ^ ^ ^ ^
# db_name + update_seq in a single line --+ | | | and back: space to comma --+
# delete quotes --+ | +-- remove string after first minus char
# comma to space (for awk values) --+
# the result is ... echo "$seq" | head -3
# the result is database name + comma + sequence id
# echo "$seq" | head -3
# _users,7688
# candidate-00649860284626638ac6fd12bf000df5,40
# candidate-04561cddbd0fa305714b48a57929d8b4,3
echo
"-----
$(
date
)
- reading current sequence ids..."
echo
"-----
$(
date
+%H:%M:%S
)
- reading current sequence ids..."
declare
-A
aSeq
for
line
in
$(
echo
"
$seq
"
)
do
...
...
@@ -300,7 +294,7 @@ function _doBackupOfSingleInstance(){
aSeq+
=([
$db
]=
$seqid
)
done
echo
"-----
$(
date
)
- reading sequence ids of last backup..."
echo
"-----
$(
date
+%H:%M:%S
)
- reading sequence ids of last backup..."
declare
-A
aSeqBackup
for
line
in
$(
cat
"
${
seqfile
}
"
2>/dev/null
)
do
...
...
@@ -312,29 +306,18 @@ function _doBackupOfSingleInstance(){
for
dbname
in
$(
cat
"
$dblistfile
"
)
do
iDb+
=
1
echo
-n
"-----
$(
date
)
${
PROFILENAME
}
--
$iDb
of
$iDbTotal
-
${
dbname
}
- "
echo
-n
"-----
$(
date
+%H:%M:%S
)
${
PROFILENAME
}
--
$iDb
of
$iDbTotal
-
${
dbname
}
- "
# set later .. OUTFILE=${BACKUP_TARGETDIR}/${COUCHDB_INSTANCE}/$(get_outfile "${dbname}").couchdbdump
ARCHIVFILE
=
${
ARCHIVE_DIR
}
/
${
dbname
}
.couchdbdump.gz
SEQFILE
=
${
ARCHIVE_DIR
}
/seq/__seq__
${
dbname
}
SECURITYFILE
=
${
ARCHIVE_DIR
}
/security/__security__
${
dbname
}
.json
#
sSequenceCurrent=$(_getDbSeq "${dbname}")
#
compare current sequence id with last backup sequence id
sSequenceCurrent
=
"
${
aSeq
[
$dbname
]
}
"
# sSequenceLast=$(cat "${SEQFILE}" 2>/dev/null | cut -f 1 -d '-')
sSequenceLast
=
"
${
aSeqBackup
[
$dbname
]
:-
$(
cat
${
SEQFILE
}
2>/dev/null |
cut
-f
1
-d
'-'
)
}
"
aSeqBackup[
${
dbname
}
]=
$sSequenceLast
if
[
"
${
sSequenceCurrent
}
"
=
"
${
sSequenceLast
}
"
]
&&
[
-f
"
$ARCHIVFILE
"
]
;
then
echo
"SKIP: still on sequence
${
sSequenceLast
}
"
# add security file for already existing databases
test
-f
"
${
SECURITYFILE
}
"
||
(
echo
"INFO: creating missing security file
${
SECURITYFILE
}
"
_couchapi GET
"
${
dbname
}
/_security"
>
"
${
SECURITYFILE
}
"
)
echo
"SKIP: still on sequence
${
sSequenceLast
}
"
else
OUTFILE
=
${
BACKUP_TARGETDIR
}
/
$(
get_outfile
"
${
dbname
}
"
)
.couchdbdump
if
[
-z
"
$sSequenceCurrent
"
]
;
then
...
...
@@ -377,7 +360,8 @@ function _doBackupOfSingleInstance(){
iTsTotal
=
$(
date
+%s
)
-
$iTsStart
iDbPerSec
=
$iDbTotal
/
$iTsTotal
echo
"-----
$(
date
)
- writing sequence ids ..."
# cache sequence ids in a file
echo
"-----
$(
date
+%H:%M:%S
)
- writing sequence ids ..."
rm
-f
"
${
seqfile
}
"
2>/dev/null
for
key
in
"
${
!aSeqBackup[@]
}
"
;
do
echo
"
$key
,
${
aSeqBackup
[
$key
]
}
"
>>
"
${
seqfile
}
"
...
...
This diff is collapsed.
Click to expand it.
plugins/localdump/ldap.sh
+
1
−
1
View file @
11220b73
...
...
@@ -116,7 +116,7 @@ function restoreByFile(){
j_requireBinary
"ldapsearch"
1
j_requireBinary
"slapcat"
1
j_requireProcess
"slapd"
1
#
j_requireProcess "slapd" 1
ls
$LDAP_CONF_DIR_PATH
>
/dev/null 2>&1
...
...
This diff is collapsed.
Click to expand it.
plugins/localdump/mysql.sh
+
1
−
1
View file @
11220b73
...
...
@@ -145,7 +145,7 @@ function mysql.db.list(){
# mysql.available || return
function
mysql.available
(){
local
_rc
;
typeset
-i
_rc
=(
1-
$mysql_FOUND
)
typeset
-i
_rc
;
_rc
=(
1-
$mysql_FOUND
)
return
$_rc
}
...
...
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