timemachine-exclude

1.0.1 • Public • Published

timemachine-exclude

A CLI tool to manage Time Machine exclusions for node_modules and other specified directories. This tool helps you prevent backing up unnecessary large directories, improving the efficiency of Time Machine backups.

Installation

npm install -g timemachine-exclude

Usage

timemachine-exclude <command> [options]

Commands

  • init: Initializes timemachine-exclude with parent directories to search in and patterns to exclude. This will create a config file in ~/.tm_exclude_config.
  • populate: Finds directories that match your exclude patterns (e.g., node_modules, dist, build) within your specified parent directories and updates the list of exclusions. This will create an exclusions file in ~/.tm_exclusions_tm_exclude.
  • apply: Applies the discovered exclusions to Time Machine.
  • update: Executes populate followed by apply to update exclusions.
  • list: Lists the current Time Machine exclusions in the exclusion file.
  • help: Displays the help message.

Examples

Initialize the tool

timemachine-exclude init

This command prompts you to enter parent directories to search for exclusions, followed by the exclusion patterns. For example:

Initializing timemachine-exclude...
Enter parent directories to search in.
Enter each directory path followed by [ENTER]. When done, enter an empty line.
Directory: ~/Projects
Directory: ~/Workspace
Directory: 

Enter directory names or patterns to exclude.
Enter each pattern followed by [ENTER]. When done, enter an empty line.
Example patterns: node_modules, dist, build, *.cache
Pattern: node_modules
Pattern: dist
Pattern: build
Pattern: 
Configuration saved to /Users/yourusername/.tm_exclude_config

Populate exclusions

timemachine-exclude populate

This command scans the specified parent directories for directories matching the exclusion patterns, then creates a list of full paths in ~/.tm_exclusions_tm_exclude

Populating exclusions...
Searching in: /Users/yourusername/Projects
Excluded: /Users/yourusername/Projects/myproject/node_modules
Searching in: /Users/yourusername/Workspace
Excluded: /Users/yourusername/Workspace/anotherproject/node_modules
Excluded: /Users/yourusername/Workspace/anotherproject/dist

All excluded directories have been listed in /Users/yourusername/.tm_exclusions_tm_exclude

Apply exclusions to Time Machine

timemachine-exclude apply

This command reads the contents of ~/.tm_exclusions_tm_exclude and applies each path to the Time Machine exclusion list.

Applying exclusions to Time Machine...
Added exclusion: /Users/yourusername/Projects/myproject/node_modules
Added exclusion: /Users/yourusername/Workspace/anotherproject/node_modules
Added exclusion: /Users/yourusername/Workspace/anotherproject/dist
All exclusions have been applied to Time Machine.

Update exclusions

timemachine-exclude update

This command runs the populate command to find new exclusions and applies them to Time Machine

List exclusions

timemachine-exclude list

This command outputs the contents of ~/.tm_exclusions_tm_exclude.

Listing current Time Machine exclusions for node_modules:
/Users/yourusername/Projects/myproject/node_modules
/Users/yourusername/Workspace/anotherproject/node_modules
/Users/yourusername/Workspace/anotherproject/dist

Configuration

The tool uses two configuration files in your home directory:

  • ~/.tm_exclude_config: Stores the parent directories to search and exclude patterns, as defined when you run the init command.
  • ~/.tm_exclusions_tm_exclude: Stores the generated list of directories to be excluded from Time Machine backups. This is generated by the populate command.

How it Works

  1. Initialization:
    • The init command allows users to define parent directories for searching and patterns of directories to exclude from the backup. This information is stored in ~/.tm_exclude_config.
  2. Populating Exclusions:
    • The populate command reads configuration details from ~/.tm_exclude_config and searches all specified directories for the patterns provided. Matching directories are listed in ~/.tm_exclusions_tm_exclude.
  3. Applying Exclusions:
    • The apply command reads the exclusion paths from ~/.tm_exclusions_tm_exclude and uses the tmutil command to add them as exclusions in Time Machine.
  4. Updating Exclusions:
    • The update command combines the populate and apply actions, refreshing the list of exclusions based on the current file system and applying those changes to Time Machine.
  5. Listing Exclusions:
    • The list command displays the currently excluded directories in ~/.tm_exclusions_tm_exclude.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i timemachine-exclude

Weekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

25.6 kB

Total Files

7

Last publish

Collaborators

  • derekbarrera