LinuxCommandLibrary

lbu

Backup and restore Alpine Linux configuration

TLDR

Commit changes to persistent storage (only files in /etc by default)

$ lbu [[ci|commit]]
copy

List files that would be saved using commit
$ lbu [[st|status]]
copy

Display changes in tracked files that would be saved using commit
$ lbu diff
copy

Include a specific file or directory in the apk overlay
$ lbu [[inc|include]] [path/to/file_or_directory]
copy

Exclude a specific file or directory in /etc from the apk overlay
$ lbu [[ex|exclude]] [path/to/file_or_directory]
copy

Display the list of manually included/excluded files
$ lbu [include|exclude] -l
copy

List backups (previously created overlays)
$ lbu [[lb|list-backup]]
copy

Revert to a backup overlay
$ lbu revert [overlay_filename.tar.gz]
copy

SYNOPSIS

lbu [options] [command] [path...]

PARAMETERS

-C

, --control
    Use dir as control directory (default: /etc/lbu)

-f , --config
    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
    Exclude files matching shell glob pattern

-I , --include
    Include files matching shell glob pattern

-e , --exclude-from
    Exclude patterns from file

-i , --include-from
    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 : Manage config rules.

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.

SEE ALSO

apk(8), mkinitfs(8), tar(1)

Copied to clipboard