mcde: backup by BorgBackup to a disk of its own, with a watcher for space
McdeSys gets the backup (lib/McdeSys/backup.c): a partition becomes the backup disk with an encrypted repository (borg init -e repokey-blake2); every hour root's crontab runs dtbackup run: borg create of / (and /home) on its own file systems, lz4, then prune -- 24 hourly, 30 daily, 52 weekly, every monthly unless set otherwise (keep_* in /etc/mcde-backup.conf, -1 keeps every one) -- and compact. The watcher: before and after each run, while the backup disk has less than min_free percent free (10 unless set), the oldest backup is deleted and the space given back; the newest is never deleted. Listing (borg list --json) and restoring a path into a folder (borg extract). The passphrase lives in /etc/mcde-backup.pass, root's alone, handed over by BORG_PASSCOMMAND. docs/reference/borg.txt from borg 1.4.5's own documentation. dtbackup run | status | list: the same from a shell and for cron, no X. Measured: builds on the Linux host and compiles in the build VM; as a user dtbackup status says no disk is set up and dtbackup run refuses. Not measured: a real backup -- borg is not on the host and goes into the set with the next userland. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5eee8d5d8f
commit
c8e8587f9b
9 files changed
+624
-3
No files matched your search
+42
-1
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* Status: lib/McdeSys implements mcde_sys_backend, mcde_sys_error,
|
||||
* mcde_sys_info, mcde_sys_power, mcde_sys_interfaces, the sound, Bluetooth,
|
||||
* battery, time zone, sharing, the network browser, disks,
|
||||
* battery, time zone, sharing, the network browser, disks, backup,
|
||||
* user and software update functions (common.c, net.c, sound.c, users.c,
|
||||
* netbsd.c, linux.c); the network setup and the host name setter are the
|
||||
* contract still.
|
||||
@@ -282,6 +282,47 @@ int mcde_sys_disk_erase(const char *name, const char *fstype,
|
||||
*/
|
||||
int mcde_sys_permissions(int repair, char *log, size_t len);
|
||||
|
||||
/*
|
||||
* Backup: the whole system, every hour, to a disk of its own, by BorgBackup
|
||||
* -- encrypted (repokey-blake2), deduplicated; kept are, unless set
|
||||
* otherwise, 24 hourly, 30 daily, 52 weekly and every monthly state, and
|
||||
* when the disk's free space falls below a share (10 %), the oldest are
|
||||
* deleted until it is back. Setting up, running, listing and restoring
|
||||
* need root.
|
||||
*/
|
||||
typedef struct {
|
||||
int configured; /* a disk and a repository are set up */
|
||||
int enabled; /* it runs every hour */
|
||||
char disk[32]; /* the partition it backs up to */
|
||||
char repo[512]; /* the repository on it */
|
||||
long long last; /* the last backup's time (time_t), or 0 */
|
||||
char result[256]; /* how the last one ended */
|
||||
/* how many are kept (-1: every one); and the free space below which
|
||||
* the oldest backups are deleted, in percent of the disk */
|
||||
int keepHourly, keepDaily, keepWeekly, keepMonthly;
|
||||
int minFree;
|
||||
} McdeSysBackup;
|
||||
|
||||
typedef struct {
|
||||
char name[128];
|
||||
char time[32]; /* "2026-11-11T14:00:03" */
|
||||
} McdeSysBackupArchive;
|
||||
|
||||
int mcde_sys_backup_get(McdeSysBackup *b);
|
||||
/* make PARTITION (mounted, or mountable) the backup disk: a repository on
|
||||
* it, encrypted with PASSPHRASE, which is kept for the hourly runs */
|
||||
int mcde_sys_backup_setup(const char *partition, const char *passphrase);
|
||||
int mcde_sys_backup_enable(int on);
|
||||
/* how many are kept and the free space to hold, from B (root) */
|
||||
int mcde_sys_backup_policy(const McdeSysBackup *b);
|
||||
/* one backup now (the hourly run does this); borg's report into LOG */
|
||||
int mcde_sys_backup_run(char *log, size_t len);
|
||||
/* the backups there are, oldest first; how many */
|
||||
int mcde_sys_backup_archives(McdeSysBackupArchive *a, size_t max);
|
||||
/* PATH (absolute, as it was) of backup ARCHIVE, into the folder DEST */
|
||||
int mcde_sys_backup_restore(const char *archive, const char *path,
|
||||
const char *dest);
|
||||
|
||||
/*
|
||||
* A process: the command line it was started with, as one line a shell
|
||||
* reads back (each argument in single quotes). For the front panel, which
|
||||
|
||||
Reference in new issue
Block a user