Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
backupninja
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Liberate
backupninja
Commits
0bce7106
Commit
0bce7106
authored
2 months ago
by
Guillaume Subiron
Browse files
Options
Downloads
Patches
Plain Diff
shellcheck borg handler
parent
6df27e0f
No related branches found
No related tags found
1 merge request
!69
Multiple improvements in borg handler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
handlers/borg.in
+20
-15
20 additions, 15 deletions
handlers/borg.in
with
20 additions
and
15 deletions
handlers/borg.in
+
20
−
15
View file @
0bce7106
#!/bin/bash
# shellcheck shell=bash
# shellcheck disable=SC2154
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
#
...
...
@@ -48,7 +51,7 @@ getconf port
getconf directory
# strip trailing /
directory
=
${
directory
%/
}
getconf archive
{
now:%Y-%m-%dT%H:%M:%S
}
getconf archive
"
{now:%Y-%m-%dT%H:%M:%S}
"
getconf compression lz4
getconf encryption none
getconf passphrase
...
...
@@ -106,21 +109,23 @@ fi
# check the connection at the source and destination
[
-n
"
$test
"
]
||
test
=
0
# shellcheck disable=SC2235
if
[
"
$host
"
!=
"localhost"
]
&&
([
"
$testconnect
"
=
"yes"
]
||
[
"
${
test
}
"
-eq
1
])
;
then
debug
"ssh
$sshoptions
-o PasswordAuthentication=no
${
host
}${
port
:+
-p
${
port
}}
-l
$user
'echo -n 1'"
local
ret
=
`
ssh
$sshoptions
-o
PasswordAuthentication
=
no
${
host
}${
port
:+
-p
${
port
}}
-l
$user
'echo -n 1'
`
teststr
=
"ssh
$sshoptions
-o PasswordAuthentication=no
${
host
}${
port
:+
-p
${
port
}}
-l
$user
'echo -n 1'"
debug
"
$teststr
"
ret
=
$(
su
-c
"
$teststr
"
)
if
[
"
$ret
"
=
1
]
;
then
debug
"Connected to
$host
as
$user
successfully"
else
teststr
=
"borg list
$options
--show-rc -v
$execstr_repository
"
debug
"
$teststr
"
output
=
`
su
-c
"
$teststr
"
2>&1
`
output
=
$(
su
-c
"
$teststr
"
2>&1
)
if
echo
"
$output
"
|
grep
"terminating with success status"
\
||
echo
"
$output
"
|
grep
"^
\S\+
is not a valid repository."
\
||
echo
"
$output
"
|
grep
"^Repository
\S\+
does not exist."
;
then
debug
"Connected to
$host
as
$user
successfully (forced command)"
else
error
$output
error
"
$output
"
fatal
"Can't connect to
$host
as
$user
."
fi
fi
...
...
@@ -132,13 +137,13 @@ if [ "$init" == "yes" ]; then
initstr
=
"borg init
$options
--encryption=
$encryption
$execstr_repository
"
debug
"executing borg init"
debug
"
$initstr
"
if
[
$test
=
0
]
;
then
output
=
"
`
su
-c
"
$initstr
"
2>&1
`
"
if
[
"
$test
"
=
0
]
;
then
output
=
"
$(
su
-c
"
$initstr
"
2>&1
)
"
if
[
$?
=
2
]
;
then
debug
$output
debug
"
$output
"
info
"Repository was already initialized"
else
warning
$output
warning
"
$output
"
warning
"Repository has been initialized"
fi
fi
...
...
@@ -168,11 +173,11 @@ IFS=$SAVEIFS
set
+o noglob
if
[
!
-z
$bwlimit
]
;
then
if
[
-n
"
$bwlimit
"
]
;
then
execstr
=
"
${
execstr
}
--remote-ratelimit=
${
bwlimit
}
"
fi
if
[
!
-z
"
$create_options
"
]
;
then
if
[
-n
"
$create_options
"
]
;
then
execstr
=
"
${
execstr
}
${
create_options
}
"
fi
...
...
@@ -235,14 +240,14 @@ if [ "$prune" == "yes" ]; then
prunestr
=
"borg prune
$options
$prune_options
$execstr_repository
"
debug
"executing borg prune"
debug
"
$prunestr
"
if
[
$test
=
0
]
;
then
output
=
"
`
su
-c
"
$prunestr
"
2>&1
`
"
if
[
"
$test
"
=
0
]
;
then
output
=
"
$(
su
-c
"
$prunestr
"
2>&1
)
"
ret
=
$?
if
[
$ret
=
0
]
;
then
debug
$output
debug
"
$output
"
info
"Removing old backups succeeded."
elif
[
$ret
=
1
]
;
then
warning
$output
warning
"
$output
"
warning
"Removing old backups finished with warnings."
else
error
$output
...
...
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