Keeps track of files that you want to backup. It does so by storing their path, so that it easily can be retrieved at a later point. Also has the ability to check the validity of the paths, and also to remove any path that is no longer valid.
The script is intended to use as an assistance when backing up system and/or application files, by piping the output of the list option (trackup.sh --list
) to a backup application or solution of choice.
All tracked files will be stored in a plain text file at location ~/.local/bin/trackup.sh.list
. It is this file that the script operates on.
This is an example of how to setup and use the script. Do note that it is nothing more than a script and that there are several ways to set things up.
$ mkdir -p ~/.local/bin && mv /path/to/trackup.sh ~/.local/bin
$ chmod u+x ~/.local/bin/trackup.sh
$ echo "export PATH='$HOME/.local/bin:$PATH'" >> ~/.bashrc
Put export in shell profile for persistency
$ echo "alias trackup='trackup.sh'" >> ~/.bashrc
This is how the script is used:
trackup.sh [-hlsc][-ar arg]
Following are some usage examples with corresponding output. They demonstrate several cases that may occur using this script, such as a adding file to be tracked, checking tracking status, performing a clean up and also how to list files that are being tracked.
$ trackup.sh --status
[+] "/just/a/file"
Only one file is being tracked.
$ trackup.sh --add somefile --add someotherfile
[+] "/path/to/somefile"
[+] "/path/to/someotherfile"
Two files were added for tracking. Note: It is possible add relative paths - the script will figure outer the absolute paths.
$ rm /path/to/somefile
$ trackup.sh --status
[ ] "/path/to/somefile"
[+] "/path/to/someotherfile"
[+] "/just/a/file"
One file that are being tracked was removed. The --status
option will show that this is the case.
$ trackup.sh -cl
Cleaned out 1 entry
/path/to/someotherfile /just/a/file
The script performed a cleanup of all files that no longer exists. After that, the remaining tracked files were displayed as a string of paths separated by a space.
$ mkdir -p ~/tmp/test
$ cp $(trackup.sh --list) /tmp/test/
$ ls /tmp/test
file someotherfile
For the sake of this example, a temporary directory is created, in which all tracked files are copied to, combining the cp
command and --list
option. The ls
command shows the files actually being there.
The script takes a number of different options. In compliance with POSIX standards, combined short options are allowed. For instance, -cl
will be interpreted the same way as --clean --list
. Furthermore, the commands will be performed in a fixed order, no matter which order you enter them:
- Show help (and then exit)
- List file status
- Clean tracked files
- List files
- Add files
- Remove files
In other words: --list --clean
will be handled as if you entered --clean --list
.
Short | Long | Argument | Description |
---|---|---|---|
-h | --help | displays the help section | |
-l | --list | prints all stored paths to stdout | |
-s | --status | checks the validity of each stored path | |
-a | --add | <PATH-TO-FILE> |
add a new file to be tracked |
-r | --remove | <PATH-TO-FILE> |
removes a previously tracked file |
-c | --clean | will remove any stored path that is not valid |
- Handle how symlinks are handled
- Handle wildcards (add all files in folder)
- Add verbose mode
- make script POSIX compliant and not reliant on bash