Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegrunwell committed Nov 25, 2017
2 parents 9f03815 + 63ac61f commit c1dbe48
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 11 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Asimov Change Log

All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).


## [0.2.0]

* Bundle the script with `com.stevegrunwell.asimov.plist`, enabling Asimov to be scheduled to run daily. Users can set this up in a single step by running the new `install.sh` script.
* Fixed pathing issue when resolving the script directory for `install.sh`. Props @morganestes. (#7)
* Change the scope of Asimov to find matching directories within the current user's home directory, not just `~/Sites`. Props to @vitch for catching this! (#10).
* Added a formal change log to the repository. (#5)


## [0.1.0]

Initial public release.


[Unreleased]: https://github.com/stevegrunwell/asimov/compare/master...develop
[0.2.0]: https://github.com/stevegrunwell/asimov/releases/tag/v0.2.0
[0.1.0]: https://github.com/stevegrunwell/asimov/releases/tag/v0.1.0
[#10]: https://github.com/stevegrunwell/asimov/issues/10
[#7]: https://github.com/stevegrunwell/asimov/issues/7
[#5]: https://github.com/stevegrunwell/asimov/issues/5
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ For the average consumer, Time Machine is an excellent choice, especially consid

Asimov aims to solve that problem, scanning your filesystem for known dependency directories (e.g. `node_modules/` living adjacent to a `package.json` file) and excluding them from Time Machine backups. After all, why eat up space on your backup drive for something you could easily restore via `npm install`?

## Usage
## Installation

After cloning the repository or downloading and extracting an archive, run the following to automatically exclude dependencies from Time Machine backups:
To get started with Asimov, clone the repository or download and extract an archive anywhere you'd like on your Mac:

```bash
# Make the script executable (you'll only need to do this once).
$ chmod +x ./asimov

# Run Asimov.
$ ./asimov
```sh
$ git clone [email protected]:stevegrunwell/asimov.git
```

You may wish to schedule Asimov to run automatically, ensuring new projects are automatically excluded from backups. Don't worry about running it multiple times, Asimov is smart enough to see if a directory has already been marked for exclusion.
After you've cloned the repository, run the `install.sh` script to automatically:
* Symlink Asimov to `/usr/local/bin`, making it readily available from anywhere.
* Schedule Asimov to run once a day, ensuring new projects' dependencies are quickly excluded from Time Machine backups.
* Run Asimov for the first time, finding all current project dependencies adding them to Time Machine's exclusion list.

## How it works

At its essence, Asimov is a simple wrapper around Apple's `tmutil` program, which provides more granular control over Time Machine.

Asimov finds recognized dependency directories, verifies that the corresponding dependency file exists and, if so, tells Time Machine not to worry about backing up the dependency directory.

Don't worry about running it multiple times, either. Asimov is smart enough to see if a directory has already been marked for exclusion.

### Retrieving excluded files

If you'd like to see all of the directories and files that have been excluded from Time Machine, you can do so by running the following command ([props Brant Bobby on StackOverflow](https://apple.stackexchange.com/a/25833/206772)):
Expand Down
4 changes: 2 additions & 2 deletions asimov
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# For a full explanation, please see https://apple.stackexchange.com/a/25833/206772
#
# @version 0.1.0
# @version 0.2.0
# @author Steve Grunwell
# @license MIT

Expand Down Expand Up @@ -67,5 +67,5 @@ for i in "${FILEPATHS[@]}"; do
printf "\\n\\033[0;36mFinding %s/ directories with corresponding %s files...\\033[0m\\n" \
"${parts[0]}" "${parts[1]}"

find ~/Sites -name "${parts[0]}" -type d | dependency_file_exists "${parts[1]}" | exclude_file
find ~ -name "${parts[0]}" -type d | dependency_file_exists "${parts[1]}" | exclude_file
done
13 changes: 13 additions & 0 deletions com.stevegrunwell.asimov.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.stevegrunwell.asimov</string>
<key>Program</key>
<string>/usr/local/bin/asimov</string>
<key>StartInterval</key>
<!-- 24 hours = 60 * 60 * 24 -->
<integer>86400</integer>
</dict>
</plist>
28 changes: 28 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Install Asimov as a launchd daemon.
#
# @author Steve Grunwell
# @license MIT

DIR="$(cd "$(dirname "$0")" || return; pwd -P)"
PLIST="com.stevegrunwell.asimov.plist"

# Verify that Asimov is executable.
chmod +x ./asimov

# Symlink Asimov into /usr/local/bin.
echo -e "\\033[0;36mSymlinking ${DIR} to /usr/local/bin/asimov\\033[0m"
ln -si "${DIR}/asimov" /usr/local/bin/asimov

# If it's already loaded, unload first.
if launchctl list | grep -q com.stevegrunwell.asimov; then
echo -e "\\n\\033[0;36mUnloading current instance of ${PLIST}\\033[0m";
launchctl unload "${DIR}/${PLIST}"
fi

# Load the .plist file.
launchctl load "${DIR}/${PLIST}" && echo -e "\\n\\033[0;32mAsimov daemon has been loaded!\\033[0m";

# Run Asimov for the first time.
"${DIR}/asimov"

0 comments on commit c1dbe48

Please sign in to comment.