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
060de685
Commit
060de685
authored
8 years ago
by
Benzhaomin
Committed by
Jérôme Charaoui
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[borg] added support for local backups, without ssh (host=localhost)
parent
2e6d94d8
No related branches found
No related tags found
1 merge request
!10
Borg support (rebased)
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/example.borg
+6
-4
6 additions, 4 deletions
examples/example.borg
handlers/borg
+6
-2
6 additions, 2 deletions
handlers/borg
handlers/borg.in
+128
-0
128 additions, 0 deletions
handlers/borg.in
with
140 additions
and
6 deletions
examples/example.borg
+
6
−
4
View file @
060de685
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
## as the commented out option, uncomment and change when
## as the commented out option, uncomment and change when
## necessary. Options which are uncommented in this example do not have
## necessary. Options which are uncommented in this example do not have
## defaults, and the settings provided are recommended.
## defaults, and the settings provided are recommended.
##
##
## The defaults are useful in most cases, just make sure to configure the
## The defaults are useful in most cases, just make sure to configure the
## destination host and user.
## destination host and user.
##
##
...
@@ -82,7 +82,7 @@ exclude = /var/lib/mysql
...
@@ -82,7 +82,7 @@ exclude = /var/lib/mysql
## put the backups under this directory, this must be set!
## put the backups under this directory, this must be set!
## an example setting would be:
## an example setting would be:
## directory = /backups
## directory = /backups
##
##
## Default:
## Default:
# directory =
# directory =
...
@@ -90,6 +90,8 @@ exclude = /var/lib/mysql
...
@@ -90,6 +90,8 @@ exclude = /var/lib/mysql
## an example setting would be:
## an example setting would be:
## host = backuphost
## host = backuphost
##
##
## set host = localhost for local backups (no ssh)
##
## Default
## Default
# host =
# host =
...
@@ -118,4 +120,4 @@ exclude = /var/lib/mysql
...
@@ -118,4 +120,4 @@ exclude = /var/lib/mysql
## for more info see : borg create -h
## for more info see : borg create -h
##
##
## Default:
## Default:
# compression = lz4
# compression = lz4
\ No newline at end of file
This diff is collapsed.
Click to expand it.
handlers/borg
+
6
−
2
View file @
060de685
...
@@ -44,7 +44,11 @@ fi
...
@@ -44,7 +44,11 @@ fi
# destination specific checks
# destination specific checks
[
"
$directory
"
!=
""
]
||
fatal
"Destination directory not set"
[
"
$directory
"
!=
""
]
||
fatal
"Destination directory not set"
execstr_repository
=
"
$user
@
$host
:
$directory
"
if
[
"
$host
"
!=
"localhost"
]
;
then
execstr_repository
=
"
$user
@
$host
:
$directory
"
else
execstr_repository
=
"
$directory
"
fi
execstr_archive
=
"
$archive
"
execstr_archive
=
"
$archive
"
### INIT IF NEEDED ###
### INIT IF NEEDED ###
...
@@ -117,4 +121,4 @@ else
...
@@ -117,4 +121,4 @@ else
warning
"Failed removing old backups."
warning
"Failed removing old backups."
fi
fi
return
0
return
0
\ No newline at end of file
This diff is collapsed.
Click to expand it.
handlers/borg.in
0 → 100644
+
128
−
0
View file @
060de685
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
#
# borg handler script for backupninja
# requires borgbackup
#
# TODO: encryption support
#
export
BORG_RELOCATED_REPO_ACCESS_IS_OK
=
yes
### GET CONFIG ###
getconf testconnect
yes
getconf nicelevel 0
setsection
source
getconf keepdaily 7
getconf keepweekly 4
getconf keepmonthly
-1
getconf include
getconf exclude
setsection dest
getconf user
getconf host
getconf directory
# strip trailing /
directory
=
${
directory
%/
}
getconf archive
{
now:%Y-%m-%d
}
getconf compression lz4
### 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
execstr_repository
=
"
$user
@
$host
:
$directory
"
else
execstr_repository
=
"
$directory
"
fi
execstr_archive
=
"
$archive
"
### INIT IF NEEDED ###
# :TODO:maethor:160509: Manage encryption
initstr
=
"borg init --encryption=none
$execstr_repository
"
debug
"
$initstr
"
if
[
$test
=
0
]
;
then
output
=
"
`
su
-c
"
$initstr
"
2>&1
`
"
if
[
$?
=
2
]
;
then
debug
$output
info
"Repository was already initialized"
else
warning
$output
warning
"Repository has been initialized"
fi
fi
### EXECUTE ###
execstr
=
"borg create --stats --compression
$compression
"
set
-o
noglob
# includes
SAVEIFS
=
$IFS
IFS
=
$(
echo
-en
"
\n\b
"
)
for
i
in
$include
;
do
includes
=
"
${
includes
}
'
$i
'"
done
IFS
=
$SAVEIFS
# excludes
SAVEIFS
=
$IFS
IFS
=
$(
echo
-en
"
\n\b
"
)
for
i
in
$exclude
;
do
excludes
=
"
${
excludes
}
--exclude '
$i
'"
done
IFS
=
$SAVEIFS
set
+o noglob
# include client-part and server-part
execstr
=
"
${
execstr
}
${
excludes
}
$execstr_repository
::
$execstr_archive
${
includes
}
"
debug
"
$execstr
"
if
[
$test
=
0
]
;
then
output
=
`
nice
-n
$nicelevel
su
-c
"
$execstr
"
2>&1
`
if
[
$?
=
0
]
;
then
debug
$output
info
"Successfully finished backing up source
$label
"
else
error
$output
fatal
"Failed backuping up source
$label
"
fi
fi
### REMOVE OLD BACKUPS ###
# borg prune
prunestr
=
"borg prune --keep-daily
$keepdaily
--keep-weekly
$keepweekly
--keep-monthly
$keepmonthly
$execstr_repository
"
debug
"
$prunestr
"
output
=
"
`
su
-c
"
$prunestr
"
2>&1
`
"
if
[
$?
=
0
]
;
then
debug
$output
info
"Removing old backups succeeded."
else
warning
$output
warning
"Failed removing old backups."
fi
return
0
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