maintenance

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package maintenance — daily Hasura metadata backup cron registration.

Installs a system-level timer that calls `nself backup hasura-metadata` at 02:00 UTC every day. Uses systemd (Linux) or launchd (macOS).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallDailyTimer

func InstallDailyTimer() error

InstallDailyTimer installs a system-level timer that runs disk-cleanup every day at 03:00 local time. On Linux it writes systemd unit files; on macOS it writes a LaunchDaemon plist. Returns an error if the required privileges are not available.

func InstallHasuraMetadataCron added in v1.0.14

func InstallHasuraMetadataCron() error

InstallHasuraMetadataCron installs a daily cron that runs Hasura metadata backup at 02:00 UTC. On Linux it writes systemd unit files; on macOS it writes a LaunchDaemon plist.

func RemoveDailyTimer

func RemoveDailyTimer() error

RemoveDailyTimer uninstalls the daily timer installed by InstallDailyTimer.

func RemoveHasuraMetadataCron added in v1.0.14

func RemoveHasuraMetadataCron() error

RemoveHasuraMetadataCron removes the timer installed by InstallHasuraMetadataCron.

Types

type CleanupResult

type CleanupResult struct {
	Before           DiskUsage
	After            DiskUsage
	DockerPruneOut   string
	LogRotationOut   string
	JournalVacuumOut string
	Errors           []error
}

CleanupResult summarises what disk-cleanup did.

func DiskCleanup

func DiskCleanup() CleanupResult

DiskCleanup runs all three cleanup steps and returns a summary. It never aborts early — it collects all errors and reports at the end.

type DiskUsage

type DiskUsage struct {
	// UsedPercent is the percentage of the disk that is in use (0-100).
	UsedPercent int
	// TotalGB is the total disk capacity in gigabytes.
	TotalGB float64
	// UsedGB is the used disk space in gigabytes.
	UsedGB float64
	// FreeGB is the free disk space in gigabytes.
	FreeGB float64
}

DiskUsage holds before/after disk utilisation for a cleanup run.

func GetDiskUsage

func GetDiskUsage() (DiskUsage, error)

GetDiskUsage returns current disk utilisation for the root filesystem ("/").

type HasuraMetadataCronStatus added in v1.0.14

type HasuraMetadataCronStatus struct {
	Enabled  bool
	Platform string
	Detail   string
}

HasuraMetadataCronStatus reports the state of the Hasura metadata backup timer.

func GetHasuraMetadataCronStatus added in v1.0.14

func GetHasuraMetadataCronStatus() HasuraMetadataCronStatus

GetHasuraMetadataCronStatus returns the current status of the Hasura metadata backup timer.

type ScheduleStatus

type ScheduleStatus struct {
	Enabled  bool
	Platform string
	Detail   string
}

ScheduleStatus reports the current state of the daily timer.

func GetScheduleStatus

func GetScheduleStatus() ScheduleStatus

GetScheduleStatus returns the current status of the daily cleanup timer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL