NAME
rmtree - save and restore permissions of objects in a directory
SYNOPSIS
rmtree save [-C working_dir] [--files] [--dirs]
rmtree apply [-C working_dir] [--files] [--dirs] [--dry-run]
rmtree diff [-C working_dir] [--files] [--dirs]
rmtree load
rmtree help
DESCRIPTION
`rmtree` is a simple version of known tool `mtree` on *BSD system. The
primary purpose of the tool is to save some basic attributes of objects
in a directory to a text file and/or restore objects' properties from
a standard input of attributes.
The tool only works on file system that supports following attributes:
- File mode (like 0644 on Linux)
- File owner
- File group
When the action `save` is used, the tool will scan the working directory
for all files and directories, and read their properties and print in
YAML format -- the readable format used by the action `apply` (or `load`.)
EXAMPLES
To back up objects' attributes to a file
rmtree save -C /path/to/working/dir | gzip -9c > backup.gz
To restore file permissions
zcat backup.gz | rmtree apply -C /path/to/working/dir
Save and load at the same time
rmtree save -C /this/dir/ | rmtree apply -C /that/dir/
To compare this directory with another one
rmtree save -C /this/dir | rmtree diff -C /that/dir
OPTIONS
Actions
help Print some help messages
save Scan for objects' attributes
apply Apply attributes to objects in working directory
load Load attribute data and print to STDOUT
diff Compare STDIN with the working directory
Options
-d --dry-run Execute `apply` in dry-run mode
-C --directory Set the working directory. The program will change
to this directory before scanning/applying attributes.
Default: current directory
-F --files Only work on files. When being used with 'diff',
all directories in working directory are ignored.
-D --dirs Only work on directories. When being used with 'diff',
all regular files in working directory are ignored.
--full-path Print absolute path when 'saving'. As the output has
the full paths, you may use the output for the action
'apply' without specifying the working directory.
(This also means that you can't apply the output to
another directory.) By default, the program prints
the relative paths.
-h --help Print help message
INSTALLATION
This ruby tool requires the rubygem 'slop' (for arguments parsing.)
To build a rubygem, try `gem build rmtree.gemspec`.
To use this tool, simply make it executable (by `chmod 755 rmtree.rb`.)
If the rubygem 'rmtree-x.y.z' was installed, the binary can be found
in the binary directory of your gem environment. (Please run the command
`gem env | grep EXECUTABLE` for details.)