Compare two Tomcat installations using rsync
Lets assume you manage multiple servers that host Java web applications using the Tomcat web server.
To quickly compare the Tomcat installations on host1 and host2, we can use the “dry-run” mode of the rsync command.
In the following example, we assume that you have ssh access to both of your Tomcat hosts, the installations are in
/opt/tomcat and the “
tomcat” system user has read access to all relevant files and directories of the installation:
ssh tomcat@host1 rsync --archive --checksum --dry-run --verbose --delete \ --exclude temp --exclude work --exclude logs --exclude webapps \ /opt/tomcat/ tomcat@host2:/opt/tomcat/
This will list
- All files that differ in checksum
- All files that only exist on host2 (look for ‘deleting [filename]’)
Run the same commands with host1 and host2 switched, to also see the files that only exist on host1.
We excluded the
logs directories because they are variable in nature.
We also excluded the
webapps directory because we only wanted to compare the base installation.