The list of features may look intimidating. The important ones are the values that you can give to the --operation modifier. The rest is a list of ancillary options to be used with the possible operations.

Port detection

The most straightforward operation is 'ports', which returns the list of ports that have been assigned to sandboxes installed under $SANDBOX_HOME (default $HOME/sandboxes).

$ ./sbtool -o ports5077 05080 05130 05131 15133 15333 06080 0

The ports followed by a "0" have been assigned but are not currently in use. The ones followed by a "1" are in use. If you need only the latter, it's easy.

$ ./sbtool -o ports --only_used5131 15133 1

If you want to use this information from a Perl script, there is an appropriate modifier.

Speaking about ports, if you want to make a custom installation of one or more sandboxes for which you need a range of ports, sbtool can help. Let's assume that you need at least 20 ports, not lower than 5130.

$ ./sbtool -o range --min_range=5130 --range_size=205134 - 5154

Moving a sandbox

Moving a sandbox has been in the wish list for long time. Finally, there is a clean way of moving a sandbox to an arbitrary location, keeping its functionality intact.For example, let's move msb_5_1_32 to /tmp/xyz, and see if it works.

$ ./sbtool -o move --source_dir=$HOME/sandboxes/msb_5_1_31 --dest_dir=/tmp/xyzthe old scripts have been saved as filename.bak

$ /tmp/xyz/start. sandbox server started

$ /tmp/xyz/useWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.1.31 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql [localhost] {msandbox} ((none)) > exitBye

# Now we move the sandbox back to its previous location

$ ./sbtool -o move --dest_dir=$HOME/sandboxes/msb_5_1_31 --source_dir=/tmp/xyzthe old scripts have been saved as filename.bak

The sbtool script knows when a sandbox is in use, and stops it before starting the moving process. After the move, all original scripts are saved as ".bak", and the current scripts are updated with the new location.

Copying a sandbox

Copying a sandbox meets a different need. You want mostly to copy the data from one server to another. You don't want to use replication, especially if it is a lot of data. sbtool can copy the data from one sandbox to another, stopping the source and destination when necessary. It will only copy across compatible versions (5.1 to 5.1 or newer, but not 5.0 to 5.1 or vice versa).When copying a data directory, sbtool skips relay-log.info, the binary logs, and the relay logs.Both the source and destination directories must be sandboxes, or the operation is refused.