update
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2025-01-11 16:55:31 +01:00
parent 2e7d4aa52b
commit b40a1f4fee
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 185 additions and 37 deletions

15
.woodpecker/build.yml Normal file
View file

@ -0,0 +1,15 @@
when:
- event: push
branch: main
steps:
- name: "PKGBUILD"
image: git.hydrar.de/jmarya/pacco-build:latest
commands:
- pacman -Syu --noconfirm
- buildpkg navos x86_64 pac.hydrar.de "$TOKEN" "$KEY"
environment:
TOKEN:
from_secret: pacco_token
KEY:
from_secret: sign_key

41
PKGBUILD Normal file
View file

@ -0,0 +1,41 @@
# Maintainer: JMARyA <jmarya@hydrar.de>
pkgname=bk
pkgver=2025.01.07_2e7d4aa
pkgrel=1
pkgdesc="backup utility"
arch=('x86_64')
url="https://git.hydrar.de/jmarya/bk"
license=("MIT")
depends=("borg" "rsync")
makedepends=("rustup" "git")
source=("${pkgname}::git+https://git.hydrar.de/jmarya/bk.git")
sha256sums=("SKIP")
pkgver() {
cd "$srcdir/$pkgname"
echo "$(date +%Y.%m.%d)_$(git rev-parse --short HEAD)"
}
prepare() {
cd "$srcdir/$pkgname"
rustup default nightly
cargo fetch
}
build() {
cd "$srcdir/$pkgname"
cargo build --release
}
check() {
cd "$srcdir/$pkgname"
cargo test --release
}
package() {
cd "$srcdir/$pkgname"
install -Dm755 "target/release/bk" "$pkgdir/usr/bin/bk"
install -Dm644 "src/systemd/bk.service" "/usr/lib/systemd/system/bk.service"
install -Dm644 "src/systemd/bk.timer" "/usr/lib/systemd/system/bk.timer"
install -Dm644 "config.toml" "/etc/bk.toml"
}

View file

@ -1,91 +1,91 @@
# Run a script before backup # Run a script before backup
start_script = "before.sh" # start_script = "before.sh"
# Run a script after backup # Run a script after backup
end_script = "after.sh" # end_script = "after.sh"
# Rsync Operation # Rsync Operation
[[rsync]] # [[rsync]]
# Directories SHOULD have trailing `/` # Directories SHOULD have trailing `/`
src = "/home/me/" # src = "/home/me/"
dest = "/backup/home/me/" # dest = "/backup/home/me/"
# Excludes # Excludes
exclude = [".cache", ".local"] # exclude = [".cache", ".local"]
# Delete entries not present in `src` from `destination` # Delete entries not present in `src` from `destination`
delete = true # delete = true
# Ensure this directory exists and it not empty before running rsync # Ensure this directory exists and it not empty before running rsync
ensure_exists = "/home" # ensure_exists = "/home"
# Make a CephFS snapshot before rsync # Make a CephFS snapshot before rsync
cephfs_snap = true # cephfs_snap = true
# Borg Operation # Borg Operation
[[borg]] # [[borg]]
# Repo to backup to # Repo to backup to
repo = "/backup/repo.borg" # repo = "/backup/repo.borg"
# Passphrase # Passphrase
passphrase = "pass" # passphrase = "pass"
# Source Directories # Source Directories
src = [ "/home/me/.config" ] # src = [ "/home/me/.config" ]
# Excludes # Excludes
exclude = [ # exclude = [
"some/dir" # "some/dir"
] # ]
# Exclude if present (example: Do not backup directories with `.nobackup`) # Exclude if present (example: Do not backup directories with `.nobackup`)
exclude_if_present = [".nobackup"] # exclude_if_present = [".nobackup"]
# Stay in one filesystem # Stay in one filesystem
one_file_system = true # one_file_system = true
# Backup change time # Backup change time
ctime = false # ctime = false
# Do not backup ACLs # Do not backup ACLs
no_acls = true # no_acls = true
# Do not backup extended attributes # Do not backup extended attributes
no_xattrs = true # no_xattrs = true
# Comment to add to the backup # Comment to add to the backup
comment = "Backup of /home/me/" # comment = "Backup of /home/me/"
# Compression # Compression
compression = "zstd,10" # compression = "zstd,10"
# Ensure directory exists before backup # Ensure directory exists before backup
ensure_exists = "/home/me" # ensure_exists = "/home/me"
# Make a CephFS snapshot before backup # Make a CephFS snapshot before backup
cephfs_snap = true # cephfs_snap = true
# Borg Check Operation # Borg Check Operation
[[borg_check]] # [[borg_check]]
# Repository to check # Repository to check
repo = "/backup/repo.borg" # repo = "/backup/repo.borg"
# Full Data Verify # Full Data Verify
verify_data = true # verify_data = true
# Repair Attempt # Repair Attempt
repair = false # repair = false
# Borg Prune Operation # Borg Prune Operation
[[borg_prune]] # [[borg_prune]]
# Repository to prune # Repository to prune
repo = "/backup/repo.borg" # repo = "/backup/repo.borg"
# Passphrase # Passphrase
passphrase = "pass" # passphrase = "pass"
keep_within = "30d" # keep_within = "30d"
keep_last = 20 # keep_last = 20
# keep_secondly = 3 # keep_secondly = 3
# keep_minutely = 3 # keep_minutely = 3
# keep_hourly = 10 # keep_hourly = 10

View file

@ -1,64 +1,138 @@
use serde::Deserialize; use serde::Deserialize;
/// Configuration structure for the backup system.
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct Config { pub struct Config {
/// Run a script before backup /// Optional script to run before starting the backup process.
pub start_script: Option<String>, pub start_script: Option<String>,
// Run a script after backup /// Optional script to run after completing the backup process.
pub end_script: Option<String>, pub end_script: Option<String>,
/// Configuration for rsync jobs.
pub rsync: Option<Vec<RsyncConfig>>, pub rsync: Option<Vec<RsyncConfig>>,
/// Configuration for Borg backup jobs.
pub borg: Option<Vec<BorgConfig>>, pub borg: Option<Vec<BorgConfig>>,
/// Configuration for Borg check jobs to verify repository integrity.
pub borg_check: Option<Vec<BorgCheckConfig>>, pub borg_check: Option<Vec<BorgCheckConfig>>,
/// Configuration for Borg prune jobs to manage repository snapshots.
pub borg_prune: Option<Vec<BorgPruneConfig>>, pub borg_prune: Option<Vec<BorgPruneConfig>>,
} }
/// Configuration for an individual rsync job.
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct RsyncConfig { pub struct RsyncConfig {
/// Source path for rsync.
pub src: String, pub src: String,
/// Destination path for rsync.
pub dest: String, pub dest: String,
/// List of patterns to exclude from synchronization.
pub exclude: Option<Vec<String>>, pub exclude: Option<Vec<String>>,
/// Whether to delete files at the destination that are not in the source.
pub delete: Option<bool>, pub delete: Option<bool>,
/// Ensure a specific directory exists before running the rsync job.
pub ensure_exists: Option<String>, pub ensure_exists: Option<String>,
/// Create CephFS snapshot before the rsync job.
pub cephfs_snap: Option<bool>, pub cephfs_snap: Option<bool>,
} }
/// Configuration for an individual Borg backup job.
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct BorgConfig { pub struct BorgConfig {
/// Borg repository path.
pub repo: String, pub repo: String,
/// Optional passphrase for the repository.
pub passphrase: Option<String>, pub passphrase: Option<String>,
/// List of source paths to include in the backup.
pub src: Vec<String>, pub src: Vec<String>,
/// List of patterns to exclude from the backup.
pub exclude: Option<Vec<String>>, pub exclude: Option<Vec<String>>,
/// List of marker files; directories containing these will be excluded.
pub exclude_if_present: Option<Vec<String>>, pub exclude_if_present: Option<Vec<String>>,
/// Whether to limit the backup to a single filesystem.
pub one_file_system: Option<bool>, pub one_file_system: Option<bool>,
/// Whether to backup ctime
pub ctime: Option<bool>, pub ctime: Option<bool>,
/// Disable backup of ACLs (Access Control Lists).
pub no_acls: Option<bool>, pub no_acls: Option<bool>,
/// Disable backup of extended attributes.
pub no_xattrs: Option<bool>, pub no_xattrs: Option<bool>,
/// Optional comment to associate with the backup.
pub comment: Option<String>, pub comment: Option<String>,
/// Compression mode to use for the backup.
pub compression: Option<String>, pub compression: Option<String>,
/// Ensure a specific directory exists before running the backup.
pub ensure_exists: Option<String>, pub ensure_exists: Option<String>,
pub cephfs_snap: Option<bool>,
/// Create CephFS snapshots before the backup.
pub cephfs_snap: Option<bool>
} }
/// Configuration for a Borg repository integrity check job.
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct BorgCheckConfig { pub struct BorgCheckConfig {
/// Borg repository path.
pub repo: String, pub repo: String,
/// Whether to verify the repository's data integrity.
pub verify_data: Option<bool>, pub verify_data: Option<bool>,
/// Whether to attempt repairs on detected issues.
pub repair: Option<bool>, pub repair: Option<bool>,
} }
/// Configuration for a Borg repository pruning job.
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct BorgPruneConfig { pub struct BorgPruneConfig {
/// Borg repository path.
pub repo: String, pub repo: String,
/// Passphrase for accessing the repository.
pub passphrase: String, pub passphrase: String,
/// Retain all archives within this time period.
pub keep_within: String, pub keep_within: String,
/// Retain the last `n` archives.
pub keep_last: Option<u32>, pub keep_last: Option<u32>,
/// Retain the last `n` secondly archives.
pub keep_secondly: Option<u32>, pub keep_secondly: Option<u32>,
/// Retain the last `n` minutely archives.
pub keep_minutely: Option<u32>, pub keep_minutely: Option<u32>,
/// Retain the last `n` hourly archives.
pub keep_hourly: Option<u32>, pub keep_hourly: Option<u32>,
/// Retain the last `n` daily archives.
pub keep_daily: Option<u32>, pub keep_daily: Option<u32>,
/// Retain the last `n` weekly archives.
pub keep_weekly: Option<u32>, pub keep_weekly: Option<u32>,
/// Retain the last `n` monthly archives.
pub keep_monthly: Option<u32>, pub keep_monthly: Option<u32>,
/// Retain the last `n` yearly archives.
pub keep_yearly: Option<u32>, pub keep_yearly: Option<u32>,
} }

9
src/systemd/bk.service Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=Backup
[Service]
Type=simple
ExecStart=/usr/bin/bk /etc/bk.toml
User=root
StandardOutput=journal
StandardError=journal

9
src/systemd/bk.timer Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=Scheduled backup
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target