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.
npm install -g timemachine-exclude
timemachine-exclude <command> [options]
-
init
: Initializestimemachine-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
: Executespopulate
followed byapply
to update exclusions. -
list
: Lists the current Time Machine exclusions in the exclusion file. -
help
: Displays the help message.
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
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
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.
timemachine-exclude update
This command runs the populate command to find new exclusions and applies them to Time Machine
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
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 theinit
command. -
~/.tm_exclusions_tm_exclude
: Stores the generated list of directories to be excluded from Time Machine backups. This is generated by thepopulate
command.
-
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
.
- The
-
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
.
- The
-
Applying Exclusions:
- The
apply
command reads the exclusion paths from~/.tm_exclusions_tm_exclude
and uses thetmutil
command to add them as exclusions in Time Machine.
- The
-
Updating Exclusions:
- The
update
command combines thepopulate
andapply
actions, refreshing the list of exclusions based on the current file system and applying those changes to Time Machine.
- The
-
Listing Exclusions:
- The
list
command displays the currently excluded directories in~/.tm_exclusions_tm_exclude
.
- The
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.
This project is licensed under the MIT License - see the LICENSE file for details.