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
70873857
Commit
70873857
authored
7 years ago
by
Benzhaomin
Committed by
Jérôme Charaoui
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[borg] fixed connection testing (thanks
@orel
)
parent
d1058620
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!10
Borg support (rebased)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
handlers/borg.in
+24
-13
24 additions, 13 deletions
handlers/borg.in
with
24 additions
and
13 deletions
handlers/borg.in
+
24
−
13
View file @
70873857
...
...
@@ -39,21 +39,10 @@ getconf compression lz4
getconf encryption
getconf passphrase
export
BORG_PASSPHRASE
=
"
$passphrase
"
### CHECK CONFIG ###
# check the connection at the source and destination
[
-n
"
$test
"
]
||
test
=
0
if
[
"
$host
"
!=
"localhost"
]
&&
([
"
$testconnect
"
=
"yes"
]
||
[
"
${
test
}
"
-eq
1
])
;
then
debug
"ssh -o PasswordAuthentication=no
$host
-l
$user
'echo -n 1'"
local
ret
=
`
ssh
-o
PasswordAuthentication
=
no
$host
-l
$user
'echo -n host is alive'
`
if
echo
$ret
|
grep
"host is alive"
;
then
debug
"Connected to
$host
as
$user
successfully"
else
fatal
"Can't connect to
$host
as
$user
."
fi
fi
# destination specific checks
[
"
$directory
"
!=
""
]
||
fatal
"Destination directory not set"
if
[
"
$host
"
!=
"localhost"
]
;
then
...
...
@@ -63,9 +52,31 @@ else
fi
execstr_archive
=
"
$archive
"
# check the connection at the source and destination
[
-n
"
$test
"
]
||
test
=
0
if
[
"
$host
"
!=
"localhost"
]
&&
([
"
$testconnect
"
=
"yes"
]
||
[
"
${
test
}
"
-eq
1
])
;
then
debug
"ssh -o PasswordAuthentication=no
$host
-l
$user
'echo -n 1'"
local
ret
=
`
ssh
-o
PasswordAuthentication
=
no
$host
-l
$user
'echo -n 1'
`
if
[
"
$ret
"
=
1
]
;
then
debug
"Connected to
$host
as
$user
successfully"
else
teststr
=
"borg list --show-rc -v
$execstr_repository
"
debug
"
$teststr
"
output
=
`
su
-c
"
$teststr
"
2>&1
`
if
echo
"
$output
"
|
grep
"terminating with success status"
;
then
debug
"Connected to
$host
as
$user
successfully (forced command)"
else
if
echo
"
$output
"
|
grep
-E
"Repository.+does not exist"
;
then
debug
"Connected to
$host
as
$user
successfully (forced command)"
else
fatal
"Can't connect to
$host
as
$user
."
fi
fi
fi
fi
### INIT IF NEEDED ###
export
BORG_PASSPHRASE
=
"
$passphrase
"
initstr
=
"borg init --encryption=
$encryption
$execstr_repository
"
debug
"
$initstr
"
...
...
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