Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
infrastructure
Commits
c6efb9b8
Commit
c6efb9b8
authored
Mar 07, 2021
by
Jelle van der Waa
🚧
Browse files
Merge branch 'borg_backup_check' into 'master'
Borg backup check See merge request
!322
parents
ddba82db
9b9e9a3e
Pipeline
#5546
passed with stage
in 43 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
roles/borg_client/templates/borg-backup.sh.j2
View file @
c6efb9b8
...
...
@@ -6,6 +6,8 @@ src="/"
snapshotdir
=
"backup-snapshot"
backup_mountdir
=
"/backup"
declare
-a
list_of_btrfs_submounts
##
# usage : is_btrfs( $path )
# return : whether $path is on a btrfs
...
...
@@ -22,6 +24,21 @@ delete_snapshot() {
btrfs subvolume delete
--commit-after
"
$1
"
}
##
# exit cleanup handler
##
cleanup
()
{
if
is_btrfs
"
$src
"
;
then
umount
-R
"
$backup_mountdir
"
for
vol
in
$list_of_btrfs_submounts
;
do
delete_snapshot
"
$vol
/
$snapshotdir
"
done
rmdir
"
$backup_mountdir
"
fi
}
trap
cleanup EXIT
if
is_btrfs
"
$src
"
;
then
# List all btrfs submounts we want to backup, e.g. homedir.archlinux.org with "/ /home"
list_of_btrfs_submounts
=
$(
findmnt
-Rl
-o
target,fstype,options / |
grep
btrfs |
grep
-v
docker |
grep
-v
"subvol=
\/
[[:alnum:]]"
|
cut
-d
' '
-f1
)
...
...
@@ -75,11 +92,3 @@ borg create -v --stats -C zstd \
-e
"
$backup_mountdir
/var/lib/docker"
\
{{
item[
'host'
]
}}
/
{{
item[
'dir'
]
}}
::
$(
date
"+%Y%m%d-%H%M%S"
)
"
$backup_mountdir
"
borg prune
-v
{{
item[
'host'
]
}}
/
{{
item[
'dir'
]
}}
--keep-daily
=
7
--keep-weekly
=
4
--keep-monthly
=
6
if
is_btrfs
"
$src
"
;
then
umount
-R
"
$backup_mountdir
"
for
vol
in
$list_of_btrfs_submounts
;
do
delete_snapshot
"
$vol
/
$snapshotdir
"
done
rmdir
"
$backup_mountdir
"
fi
roles/prometheus_exporters/templates/prometheus-borg-textcollector.service.j2
View file @
c6efb9b8
[Unit]
Description=Prometheus Borg Exporter TextCollector
After=network.target
ConditionPathExistsGlob=!/root/.cache/borg/*/lock.roster
# If the backup snapshot path exists, the backup script runs and a borg
# lockfile exists and we can't run borg list
ConditionPathExists=!/backup
[Service]
Type=oneshot
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment