Skip to content
/ baccy Public

Informative, simple, and flexible backup tool based on directory synchronization; written in Rust.

License

Notifications You must be signed in to change notification settings

crowbait/baccy

Repository files navigation

baccy

Informative, simple, and flexible backup tool based on directory synchronization; written in Rust.

demo


Contents

Features

  • scanning for changed/new files in parallel to copying
  • meaningul output and status
  • mirrors directories (= removes files and directories no longer present in source)
    • optional skip for delete step
  • optional JSON configuration file for defining multiple jobs at once, without needing external scripting
  • flexible exclusion and inclusion rules
  • ... and more: check the available JSON and CLI options

Configuration

CLI

baccy [OPTIONS] <SOURCE/JSON> [TARGET]

Parameter Description
OPTIONS Optional flags and options, see Options
SOURCE / JSON Mandatory
Path to either a source folder or a JSON config file.
Parsing depends on TARGET parameter: if a target is given, this is interpreted as a directory; otherwise, it is interpreted as a JSON file to read.
TARGET Path to a destination folder. This will directly contain the contents of the source folder.

Options

Option Alias Description
--exclude-dirs <RULES>[1][2] --xd
-d
Exclude all directories (recursively) having an exactly matching name.
--exclude-files <RULES>[1][2] --xf
-f
Exclude all files having an exactly matching name.
--exclude-patterns <RULES>[1][2] --xp
-p
Exclude all paths matching a pattern.
--include-dirs <RULES>[1][2] --id Include only directories having an exactly matching name.
--include-files <RULES>[1][2] --if Include only files having and exactly matching name.
--include-patterns <RULES>[1][2] --ip Include only paths matching a pattern.
--force-include-dirs <RULES>[1][2] --fid Forces inclusion (overriding ex- and inclusions) of matching directory names.
--force-include-files <RULES>[1][2] --fif Forces inclusion (overriding ex- and inclusions) of matching file names.
--force-include-patterns <RULES>[1][2] --fip Forces inclusion (overriding ex- and inclusions) of paths matching a pattern.
--no-delete[3] --nd Skips the "delete files from target not present in source" step.
--log-files[3] --lf
-l
Prints names of files being copied and deleted to the console.
--log-rules[3] --lr Prints applied exclude-, include-, and force-include rules for each operation.
  • 1: This option accepts one or multiple values.
  • 2: When running in JSON-config-mode, any values passed to this option via the command line will be merged with the corresponding global options in the JSON (eg: JSON: "exclude_dirs":["dir1"], cli: --xd dir2, result: ["dir1", "dir2"]).
  • 3: When running in JSON-config-mode, passing this option via the command line will override all equivalent global and per-operation settings set in the JSON.

JSON

Property Type Description
exclude_dirs[1] string[] Exclude exactly matching directory names globally (for all operations).
exclude_files[1] string[] Exclude exactly matching file names globally (for all operations).
exclude_patterns[1] string[] Exclude paths matching patterns globally (for all operations).
include_dirs[1] string[] Include only exactly matching directory names globally (for all operations).
include_files[1] string[] Include only exactly matching file names globally (for all operations).
include_patterns[1] string[] Include only paths matching patterns globally (for all operations).
force_include_dirs[1] string[] Force-include exactly matching directory names globally (for all operations).
force_include_files[1] string[] Force-include exactly matching file names globally (for all operations).
force_include_patterns[1] string[] Force-include paths matching patterns globally (for all operations).
log_files[2] bool[3] Prints names of files being copied and deleted to the console.
log_rules[2] bool[3] Prints applied exclude-, include-, and force-include rules for each operation.
drive_info string[] After all operations have concluded, prints information about drive usage (used/total). Will take mount points (for Unix) or drive letters (Windows).
post_commands string[] Runs commands on /bin/sh / CMD after all operations have finished; one string for each command to run.
wait_on_end bool Waits with "Press Enter to continue" instead of self-terminating.
Intended to be used when running in some sort of autostart; to be able to see drive info or command output.
operations Operation[] Mandatory
Array of operation definitions.
  • 1: This value will be merged with its per-operation equivalent (eg: global: "exclude_dirs":["dir1"], operation: "exclude_dirs":["dir2], result: ["dir1", "dir2"]).
  • 2: This option will override the equivalent per-operation setting for all operations.
  • 3: Has absolutely no effect if set to false; same as omitting.

Operation

Property Type Description
source string Mandatory
Source directory to copy from.
target string Mandatory
Path to a destination folder. This will directly contain the contents of the source folder.
exclude_dirs string[] Exclude exactly matching directory names.
exclude_files string[] Exclude exactly matching file names.
exclude_patterns string[] Exclude paths matching patterns.
include_dirs string[] Include only exactly matching directory names.
include_files string[] Include only exactly matching file names.
include_patterns string[] Include only paths matching patterns.
force_include_dirs string[] Force-include exactly matching directory names.
force_include_files string[] Force-include exactly matching file names.
force_include_patterns string[] Force-include paths matching patterns.
no_delete bool Skips the "delete files from target not present in source" step.
log_files bool Prints names of files being copied and deleted to the console.
log_rules bool Prints applied exclude-, include-, and force-include rules for each operation.

Example

{
  "exclude_dirs": ["node_modules", "venv"],
  "drive_info": ["C", "D"],
  "post_commands": ["echo \"completed\" > log.txt"],
  "wait_on_end": true,
  "log_rules": true,

  "operations": [
    {
      "source": "C:/Documents",
      "target": "D:/Documents-backup",
      "exclude_dirs": ["Taxes"],
      "force_include_files": ["tax_return_latest.pdf"]
    },
    {
      "source": "C:/Documents/Taxes",
      "target": "D:/Taxes-backup-complete"
      "no_delete": true,
    }
  ]
}

Additional Information

Exclusions & Inclusions

Important

Directory rules are recursive: if a directory rules is given, it applies to directories and files with a matching directory name somewhere in its parent path. Eg: directory exlude dir1 will exclude dir1/dir2/file1.

  • Exclusions are simple: any path that hits any of the given rules will not be copied.
  • Inclusions are not the reverse operation; they are the opposite: if any inclusion rules are set, only paths matching one (or more) inclusion rules will be copied (see below to how rules are applied and combined). Everything else is effectively excluded. If you don't specify any inclusion rules, all files will be considered "included".
  • Force-Inclusions override both exclusions as well as inclusions; they force the file to be considered for copying.

Note

  • Exclusions are combined with a logical OR - anything that hits any rule will be excluded.
  • Inclusions are:
    • combined with a logical AND across categories and a logical OR within categories. This means that, if both directory and file name rules are passed (not empty), any file must match any directory rule and any file rule to be included. The same logic extends to patterns.
    • checked after exclusions have been checked; an excluded path will not be included if targeted this way.
  • Force-Inclusions are combined with a logical OR - anything that hits any rule will be forced to be included.

Patterns

Patterns are defined in glob style.

Patterns are matched against the relative path, relative to the source directory. This means that the entire path must match. To - for example - target all PDF files, you'd write **/*.pdf, the ** matching "none or more arbitrary directory levels".

Todo

  • remodel ETA behavior:
    • replace ETA in scanner progress with message
    • set message: scanner ETA + copy ETA
    • show speed on copy bar
    • show ETA on file bar
  • make scanner channel limit optional
  • log-only mode for pipe-able output
  • add drive info / wait-on-end options to CLI

About

Informative, simple, and flexible backup tool based on directory synchronization; written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages