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]

PARAMETERS

-c config_file
    Specify an alternative configuration file.

-d directory
    Specify a different directory to store the backups (default /media/lbu or /mnt/lbu).

-m
    Create a tarball of modules which are not part of the default kernel.

-p
    Include installed packages in the backup.

-P
    Include installed packages, with their data files, in the backup.

package
    Back up only the configuration files for specific packages.

-v
    Be verbose.

-f
    Force overwrite of existing backup files.

-i
    Run interactively.

list
    List the contents of the backup archive.

backup
    Create a new backup archive.

commit
    Commit changes to the lower layer of the overlayfs (if supported).

purge
    Remove old backups based on retention policy.

DESCRIPTION

The lbu (Linux Build Util) command is a tool primarily used in embedded Linux systems, particularly those based on Alpine Linux, to manage and back up overlayfs-based root filesystems. It facilitates creating archives (often called 'snapshots' or 'backups') of the current root filesystem state. These archives contain only the modified files stored in the upper layer of the overlayfs, making them relatively small and efficient. The primary purpose of lbu is to enable easy rollback to previous system states, making system updates and configuration changes safer and more manageable. It is designed to handle configurations stored in /etc, along with packages installed on the system, and will save them in /media/lbu or /mnt/lbu in a tar.gz file called lbu.tar.gz.

CAVEATS

lbu is highly dependent on the underlying overlayfs setup and configuration. Its functionality might be limited or unreliable if the overlayfs is not properly configured or if the system deviates significantly from the expected Alpine Linux environment. Also, blindly restoring backups without understanding their content can lead to system instability or data loss.

BACKUP LOCATION

By default, lbu stores backups in /media/lbu or /mnt/lbu. It is crucial that this location has sufficient free space. The backup location can be changed with the '-d' option.

CONFIGURATION FILE

The configuration file (usually /etc/lbu/lbu.conf) defines which files and directories are included or excluded from the backup. It allows for fine-grained control over the backup process.

WORKFLOW EXAMPLE

Typical usage:
1. Modify configuration files or install packages.
2. Run 'lbu backup' to create a backup.
3. If changes cause problems, restore the backup by replacing the files in the upper layer of the overlayfs with those from the backup.

RESTORATION

Restoring lbu backups typically involves extracting the archive and copying the files to the overlayfs upper layer. This process needs to be done carefully to avoid overwriting important data or creating inconsistencies.

HISTORY

lbu was developed as part of the Alpine Linux project to provide a simple and reliable way to manage the state of embedded systems that rely on overlayfs for their root filesystem. It addresses the need for efficient backups and rollback capabilities in environments where system updates and modifications are frequent.
It evolved to streamline the process of saving configuration changes and installed packages, allowing for quick recovery to a known-good state after software upgrades or misconfigurations.
The development focused on minimizing the size of backups and simplifying the restoration procedure.

SEE ALSO

overlayfs(5), tar(1)

Copied to clipboard