2 releases (1 stable)

1.0.0 Jan 28, 2024
0.2.0 Jan 10, 2024

#1099 in Filesystem

Zlib license

53KB
1K SLoC

Baxzup

Baxzup is a program that creates backups (or any archive, really) using XZ compression.
The backup can be configured from a simple TOML.

Installation & Usage

cargo install baxzup

When Baxzup is first run, it will generate the default configuration and wait for an input before proceeding (To allow for the configuration to be edited first).
Every next time Baxzup is run, unless the configuration goes missing, it will automatically start creating the backup.
The path to the configuration can be changed using the --config-path flag. To skip reading the configuration from a file altogether and just using the default one, --default-config can be used.

Configuration

Field Type Description Default
backup.paths [String, ...] Paths to the directories/files to add to the backup. Windows:
['C:\']

Linux:
["/etc", "/home", "/root", "/var"]

MacOS:
["/Users", "/Applications", "/Library"]
backup.exclude [String, ...] List of patterns to exclude.
If the path the program is currently checking contains any of the patterns, it will skip it.
The pattern can be a regex by typing ?/pattern/flags.
Windows:
["?/cache/i", 'C:\Program Files', 'C:\Program Files (x86)', 'C:\Windows']

Linux and MacOS:
["?/cache/i"]
backup.exclude_tags Table<String> List of tags to exclude.
If a directory contains any file named like the tag (the table's keys) it will be skipped.
The tag mode (the keys' value) defines how to skip the directory:

keep-tag:
Keep the directory and the tag file, but skip every other file in the directory.

keep-dir:
Keep the directory, but leave it empty.

keep-none:
Don't keep anything.
{ "CACHEDIR.TAG" = "keep-tag" }
backup.follow_symlinks bool The program will archive whatever the symlink is linking to rather than the symlink itself.
Following symlinks may cause the program to get stuck in a loop, use carefully.
false
backup.ignore_unreadable_files bool When unable to read a file, the program will skip it immediately instead of asking the user. false
backup.force_overwrite bool If a file with the same name as the backup already exists the program will automatically overwrite it instead of asking the user. false
backup.name String The name (or path) to the backup file, supports strftime-like formatting with some extra specifiers:

%!hostname:
The system's hostname, or "unknown" if it couldn't be obtained.

%!systemname:
The system's name or "unknown" if it couldn't be obtained.

%!systemid:
The system's distribution id.

%!username:
The username, or "unknown" if it couldn't be obtained.

%!groupname:
The user's group name, or "unknown" if it couldn't be obtained (unobtainable on Windows).
%!hostname (%F).tar.xz
progress_bars.enable bool The program will show 2 progress bars displaying how much was archived and how much was compressed.
The progress bars aren't accurate, and are simply for having a rough idea of how much was done and how much is left.
true
progress_bars.spinner_chars String The characters used in the spinner's animation, the last character is used when the progress bar is completed.
Must contain at least 2 characters.
Unicode supported:
⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏

ASCII only:
|/-\
progress_bars.progress_chars String The characters used in the progress bar, the first character is used for the filled part of the bar, while the last character is used for the empty part of the bar.
Any other character, if present, will be used for the character in the progress bar that is going to be filled next.
Must contain at least 2 characters.
█░
progress_bars.tar_bar_color String The color to be used for the "Archiving" progress bar, the string must contain either the color's name or its number.
The color of only the empty part of the bar can be additionally added using / to separate it from the filled part's color.
If only one color is given, it will be used for both parts.
yellow
progress_bars.xz_bar_color String The color to be used for the "Compressing" progress bar, the string must contain either the color's name or its number.
The color of only the empty part of the bar can be additionally added using / to separate it from the filled part's color.
If only one color is given, it will be used for both parts.
magenta
xz.level u32 (0-9) The compression level for XZ, smaller levels are faster and use less memory, but will compress less. 8
xz.threads u32 Amount of threads used by XZ. Amount of cores in the CPU.
xz.block_size u64 The size of each uncompressed block in bytes, every thread will allocate around 3 times the block size in bytes.
Set this to 0 to let XZ choose the block size.
0
auto_update_config bool If defined and set to true, the configuration will be automatically updated if any outdated field is detected. None.

When the configuration file isn't present a new one will be automatically created using the default values.
Additionally, from the CLI, flags can be used to modify most of the configuration.

Dependencies

~12–41MB
~663K SLoC