Compare commits
No commits in common. "3f4c9fc6f41d893b51607c9f04f9564a147629d4" and "0b93a91b59a80ea9207f6d9f1f94298d3a7a81ac" have entirely different histories.
3f4c9fc6f4
...
0b93a91b59
44
.drone.yml
44
.drone.yml
@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: default
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: docker.asperti.com/paspo/docker-deb-builder:debian_bullseye
|
|
||||||
commands:
|
|
||||||
- debuild -i -us -uc
|
|
||||||
- mkdir debs
|
|
||||||
- mv ../*.deb debs/
|
|
||||||
|
|
||||||
- name: gitea release
|
|
||||||
image: plugins/gitea-release
|
|
||||||
settings:
|
|
||||||
checksum:
|
|
||||||
- md5
|
|
||||||
- sha256
|
|
||||||
api_key:
|
|
||||||
from_secret: gitea_token
|
|
||||||
base_url: https://git.asperti.com
|
|
||||||
files:
|
|
||||||
- debs/*.deb
|
|
||||||
title: server01-crowdsec-whitelist
|
|
||||||
|
|
||||||
- name: push to repo
|
|
||||||
image: docker.asperti.com/paspo/docker-aptly-pusher
|
|
||||||
settings:
|
|
||||||
api_url: https://deb.server01.it/api
|
|
||||||
repo: server01
|
|
||||||
distribution: server01
|
|
||||||
http_user:
|
|
||||||
from_secret: repo_http_user
|
|
||||||
http_pass:
|
|
||||||
from_secret: repo_http_pass
|
|
||||||
passphrase:
|
|
||||||
from_secret: repo_passphrase
|
|
||||||
files:
|
|
||||||
- debs/*.deb
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- tag
|
|
20
README.md
20
README.md
@ -1,21 +1,3 @@
|
|||||||
# btrkbk-cron
|
# btrkbk-cron
|
||||||
|
|
||||||
btrbk cron wrapper with healthchecks support.
|
btrbk cron wrapper
|
||||||
|
|
||||||
[](https://drone.asperti.com/paspo/btrbk-cron)
|
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
Run this:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
debuild -i -us -uc
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
Just install the package as usual.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo dpkg -i btrbk-cron_*.deb
|
|
||||||
```
|
|
53
btrbk-cron
53
btrbk-cron
@ -1,53 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
CONF=/etc/btrbk/btrbk-cron.conf
|
|
||||||
LOGFILE=$(mktemp)
|
|
||||||
trap 'rm -f -- "${LOGFILE}"' EXIT
|
|
||||||
|
|
||||||
if [[ ! -f "${CONF}" ]] ; then
|
|
||||||
echo "Warning: Can't read config file (${CONF}), healthchecks disabled."
|
|
||||||
else
|
|
||||||
# shellcheck disable=SC1090,SC1091
|
|
||||||
source "${CONF}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
HEALTHCHECK_URL=${HEALTHCHECK_URL:-http://127.0.0.1}
|
|
||||||
HEALTHCHECK_ENABLE=${HEALTHCHECK_ENABLE:-false}
|
|
||||||
CURLOPTS=(-fsS -m 10 --retry 5)
|
|
||||||
|
|
||||||
if [[ ! -d /run/btrbk ]] ; then
|
|
||||||
mkdir -p /run/btrbk
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "---" | tee -a "${LOGFILE}"
|
|
||||||
echo "Start backup: $(date||true)" | tee -a "${LOGFILE}"
|
|
||||||
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
|
||||||
curl "${CURLOPTS[@]}" "${HEALTHCHECK_URL}/start"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
echo "healthcheck notified! (start)" | tee -a "${LOGFILE}"
|
|
||||||
(nice -n 19 /usr/bin/ionice -c idle /usr/bin/btrbk -v --progress run >> "${LOGFILE}" ; ) 2>&1
|
|
||||||
ret=$?
|
|
||||||
if [[ "${ret}" -eq "0" ]]; then
|
|
||||||
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
|
||||||
curl "${CURLOPTS[@]}" "${HEALTHCHECK_URL}"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
echo "healthcheck notified! (ok)" | tee -a "${LOGFILE}"
|
|
||||||
else
|
|
||||||
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
|
||||||
curl "${CURLOPTS[@]}" "${HEALTHCHECK_URL}/fail"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
echo "healthcheck notified! (fail)" | tee -a "${LOGFILE}"
|
|
||||||
fi
|
|
||||||
echo "starting cleanup" | tee -a "${LOGFILE}"
|
|
||||||
(nice -n 19 /usr/bin/ionice -c idle /usr/bin/btrbk clean >> "${LOGFILE}" ; ) 2>&1
|
|
||||||
|
|
||||||
echo "backup finished, sending logs" | tee -a "${LOGFILE}"
|
|
||||||
if [[ "${HEALTHCHECK_ENABLE}" = "true" ]] ; then
|
|
||||||
curl "${CURLOPTS[@]}" --data-binary "@${LOGFILE}" "${HEALTHCHECK_URL}/log"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
rm -f -- "${LOGFILE}"
|
|
||||||
echo "backup finished"
|
|
@ -1,2 +0,0 @@
|
|||||||
HEALTHCHECK_ENABLE=true
|
|
||||||
HEALTHCHECK_URL=https://my.selfhosted.healthcheck.com/ping/e48e4add-c17c-467c-9a91-7b245ad57fe8
|
|
6
debian/.gitignore
vendored
6
debian/.gitignore
vendored
@ -1,6 +0,0 @@
|
|||||||
debhelper-build-stamp
|
|
||||||
*.debhelper.log
|
|
||||||
*.substvars
|
|
||||||
files
|
|
||||||
.debhelper
|
|
||||||
btrbk-cron
|
|
1
debian/btrbk-cron.cron.d
vendored
1
debian/btrbk-cron.cron.d
vendored
@ -1 +0,0 @@
|
|||||||
25 * * * * root /usr/bin/btrbk-cron
|
|
1
debian/btrbk-cron.example
vendored
1
debian/btrbk-cron.example
vendored
@ -1 +0,0 @@
|
|||||||
btrbk-cron.conf.example etc/btrbk/btrbk-cron.conf.example
|
|
1
debian/btrbk-cron.install
vendored
1
debian/btrbk-cron.install
vendored
@ -1 +0,0 @@
|
|||||||
btrbk-cron usr/bin
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
@ -1,5 +0,0 @@
|
|||||||
btrbk-cron (0.1) UNRELEASED; urgency=medium
|
|
||||||
|
|
||||||
* Initial release.
|
|
||||||
|
|
||||||
-- Paolo Asperti <paolo@asperti.com> Wed, 18 Sep 2024 09:14:20 +0200
|
|
1
debian/compat
vendored
1
debian/compat
vendored
@ -1 +0,0 @@
|
|||||||
12
|
|
15
debian/control
vendored
15
debian/control
vendored
@ -1,15 +0,0 @@
|
|||||||
Source: btrbk-cron
|
|
||||||
Section: admin
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Paolo Asperti <paolo@asperti.com>
|
|
||||||
Build-Depends: debhelper (>= 12)
|
|
||||||
Standards-Version: 4.5.0
|
|
||||||
Homepage: https://asperti.com/
|
|
||||||
|
|
||||||
Package: btrbk-cron
|
|
||||||
Architecture: all
|
|
||||||
Depends: ${misc:Depends}, bash (>= 5), curl, btrbk
|
|
||||||
Description: btrbk wrapper script for cron and healthchecks
|
|
||||||
This packages automates btrbk and adds support for healthchecks notifications.
|
|
||||||
Healthchecks pings are sent at start and at success/failure.
|
|
||||||
Logs are also sent.
|
|
27
debian/copyright
vendored
27
debian/copyright
vendored
@ -1,27 +0,0 @@
|
|||||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
||||||
Upstream-Name: btrbk wrapper script for cron and healthchecks
|
|
||||||
Source: https://asperti.com
|
|
||||||
|
|
||||||
Files: *
|
|
||||||
Copyright: Copyright 2024 Paolo Asperti <paolo@asperti.com>
|
|
||||||
License: GPL-2+
|
|
||||||
This program is free software; you can redistribute it
|
|
||||||
and/or modify it under the terms of the GNU General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 of the License, or (at your option) any later
|
|
||||||
version.
|
|
||||||
.
|
|
||||||
This program is distributed in the hope that it will be
|
|
||||||
useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
||||||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. See the GNU General Public License for more
|
|
||||||
details.
|
|
||||||
.
|
|
||||||
You should have received a copy of the GNU General Public
|
|
||||||
License along with this package; if not, write to the Free
|
|
||||||
Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301 USA
|
|
||||||
.
|
|
||||||
On Debian systems, the full text of the GNU General Public
|
|
||||||
License version 2 can be found in the file
|
|
||||||
`/usr/share/common-licenses/GPL-2'.
|
|
4
debian/rules
vendored
4
debian/rules
vendored
@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/make -f
|
|
||||||
|
|
||||||
%:
|
|
||||||
dh $@
|
|
1
debian/source/format
vendored
1
debian/source/format
vendored
@ -1 +0,0 @@
|
|||||||
3.0 (native)
|
|
Loading…
x
Reference in New Issue
Block a user