Skip to content

IohannRabeson/tmignore-rs

Repository files navigation

tmignore-rs codecov

Makes Time Machine respect .gitignore files.
This tool is a drop-in replacement for tmignore but with a brand new command 'monitor' that will in (almost) real time update the cache if changes on the filesystem are detected.

It will happily import the tmignore cache and configuration the first time it is launched.

Compared to tmignore it should be very fast, where tmignore would take minutes it's now a few seconds.

Requirements

This program runs on MacOS only and requires Git to be installed.

Installation

The easiest is to use Homebrew:

brew install IohannRabeson/tap/tmignore-rs
brew services start tmignore-rs

You only have to do that once, tmignore-rs will be started automatically on startup.

You can stop the service using:

brew services stop tmignore-rs

Releases

You can also download the binary in the releases page. When downloading the binary from Github, you will have to convince MacOS it's ok to execute it (by removing the quarantine attribute):

xattr -cr tmignore-rs

This is not needed if you install tmignore-rs using brew.

Nix

If you use Nix with flakes enabled, you can install tmignore-rs directly from the repository:

nix profile install github:IohannRabeson/tmignore-rs

Or run it once without installing:

nix run github:IohannRabeson/tmignore-rs -- --help

A development shell with the Rust toolchain is also available:

nix develop github:IohannRabeson/tmignore-rs

How to use it

monitor command

The most important command is the monitor command:

tmignore-rs monitor

It will monitor the filesystem and update the list of paths to exclude from Time Machine backups every 60 seconds.

This program loads ~/.config/tmignore-rs/config.json as its configuration file, creating it on first run if it doesn't exist.
This configuration file is hot-reloaded so you don't need to restart tmignore-rs after modifying it. See Configuration for more details.

This command is very light, except the initial scan, it should never affect the performances of you Mac. If you want to test you can run it with the flag --dry-run to prevent it from modifying anything.
But for testing, it's easier to use the run command.

run command

This command performs a scan of the directories. You can specify the number of threads to use during this phase, no need to set it high you will be limited by the I/O anyways.
Like monitor, the run command has an option --dry-run. If you want to run tmignore-rs manually from time to time this is the command to use.

reset command

This command removes everything from the backup exclusion list.

list command

This command prints the backup exclusion list.

There is a -0 option if you want a null separated list.

path command

This command prints paths of files used by the application.

stats command

This command prints statistics.

Logs

This application sends the logs to the Console application.
Use tmignore-rs as filter (select filter by process).

Show help

tmignore-rs --help
Makes Time Machine respect .gitignore files

Usage: tmignore-rs [OPTIONS] <COMMAND>

Commands:
  monitor  Watch for file changes and keep the exclusion list up to date
  run      Scan for paths to add or remove from the backup exclusion list
  list     Print the backup exclusion list
  reset    Reset the backup exclusion list
  path     Print the paths of the files used by the application
  stats    Print statistics
  help     Print this message or the help of the given subcommand(s)

Options:
  -v, --verbose  Enable verbose logging
      --help     
  -V, --version  Print version

You can also get help about a specific command:

tmignore-rs monitor --help

Configuration

The configuration file is located at ~/.config/tmignore-rs/config.json.
You can find this path using the path command. Here is the default configuration created automatically the first time you run tmignore-rs.
If you were using tmignore the configuration will be imported.

{
  "search_directories": [
    "~"
  ],
  "ignored_directories": [
    "~/.Trash",
    "~/Applications",
    "~/Downloads",
    "~/Library",
    "~/Music/Music",
    "~/Music/iTunes",
    "~/Pictures/Photos Library.photoslibrary"
  ],
  "whitelist_patterns": [
  ],
  "threads": 4,
  "debounce_duration": "2s"
}

search_directories

The list of the directories to scan.

ignored_directories

The list of directories to ignore.

whitelist_patterns

The list of entries that should always be included in backup. The whitelist_patterns array expects glob-style patterns:

threads

The threads count. 0 means the count of threads is not limited and the max will be chosen.

debounce_duration

Debounce duration, a delay allowing to collect similar events and process them all at once. Default is 2 seconds. The maximum is 1 minute.

Coverage

I'm using Tarpaulin to measure test coverage. When developing run tarpaulin before doing changes, then run it later with your changes and tarpaulin will tell you how the coverage progressed.

Coverage chart

About

Makes Time Machine respect .gitignore files

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors