lbu
Backup and restore Alpine Linux configuration
TLDR
Commit changes to persistent storage (only files in /etc by default)
List files that would be saved using commit
Display changes in tracked files that would be saved using commit
Include a specific file or directory in the apk overlay
Exclude a specific file or directory in /etc from the apk overlay
Display the list of manually included/excluded files
List backups (previously created overlays)
Revert to a backup overlay
SYNOPSIS
lbu [options] [command] [path...]
PARAMETERS
-C
Use dir as control directory (default: /etc/lbu)
-f
Use file as config file (default: /etc/lbu/lbu.conf)
-l, --list
List files included in the backup
-q, --quiet
Reduce output verbosity
-v, --verbose
Increase output verbosity
-d
Delete specified paths from backup (used with commit)
-E
Exclude files matching shell glob pattern
-I
Include files matching shell glob pattern
-e
Exclude patterns from file
-i
Include patterns from file
-b, --boot-only
Limit to boot-required files only
DESCRIPTION
The lbu (Local Backup Utility) is a tool in Alpine Linux for managing persistent changes on read-only root filesystems, such as squashfs images common in embedded systems, containers, and diskless setups. It tracks file modifications made to the live overlay filesystem and allows committing them to a compact backup stored in /etc/lbu. On boot, these backups are automatically applied via the initramfs (if configured with mkinitfs), ensuring configurations survive reboots or system reinstalls.
Workflow: Use lbu status to preview changes, lbu commit to save them selectively, and lbu package myconfig.apk to export as an installable APK for distribution. Excludes and includes are managed via /etc/lbu/lbu.conf, supporting regex patterns for precise control (e.g., excluding caches or temp files). Backups can be generated as tarballs or APKs, facilitating reproducible deployments.
This utility is essential for Alpine's lightweight, secure design, minimizing writable storage while preserving essential configs like /etc tweaks, network settings, or services.
CAVEATS
Alpine Linux-specific; requires mkinitfs hooks for boot-time application. Backups ignore unchanged files; test with lbu status. Not suitable for large data persistence.
COMMON COMMANDS
status [path...]: Show modified files ready for backup.
commit [path...]: Save changes to backup.
generate: Create full backup tarball.
package [name.apk]: Export backup as APK.
tree: Display backup as directory tree.
include/exclude
CONFIG FILE
/etc/lbu/lbu.conf defines global includes/excludes with lines like /bin/* -exclude or /etc/*. Supports .include and .exclude directives.
HISTORY
Introduced in early Alpine Linux (circa 2009-2010) to support read-only roots in embedded/VPS/container environments. Evolved with APK integration for easier packaging; maintained by Alpine developers for minimalism and reproducibility.


