A Java facade for rclone sync operations with progress tracking support. This library provides a fluent API to execute rclone sync commands and monitor their progress in real-time.
- Fluent API for configuring and running rclone sync operations
- Real-time progress tracking
- Support for checksum verification
- File exclusion patterns support
- Java 17 or higher
- rclone installed and available in system PATH
<dependency>
<groupId>com.fathzer</groupId>
<artifactId>rclone-sync4j</artifactId>
<version>0.0.1</version>
</dependency>implementation 'com.fathzer:rclone-sync4j:0.0.1'RcloneSync sync = new RcloneSync("local/path", "remote:path")
.withCheckSum(true) // Enable checksum verification
.withExcludesFile("exclude-patterns.txt") // Optional: exclude files
.withEventConsumer(progress ->
// Handle progress updates
System.out.printf("Progress: %s / %s%n",
progress.processedChecks(), progress.totalChecks());
)
.withExceptionConsumer(Exception::printStackTrace);
Synchronization syncOp = sync.run();
syncOp.waitFor(); // Wait for sync to complete
SynchronizationResult result = syncOp.result();
System.out.println("Sync completed: " + result);If you already have rclone configured on your machine, the library will use your existing configuration file, typically located at:
~/.config/rclone/rclone.confon Linux/macOS%APPDATA%\rclone\rclone.confon Windows
If rclone is not configured on the machine, you have two options:
-
Create a configuration file manually:
# Create config directory mkdir -p ~/.config/rclone/ # Create a minimal rclone config cat > ~/.config/rclone/rclone.conf << 'EOL' [remote] type = your_remote_type # e.g., s3, google drive, dropbox, etc. # Add your remote configuration here EOL
-
Use a custom config file location with
withConfigFile:RcloneSync sync = new RcloneSync("source", "remote:path") .withConfigFile("/path/to/your/rclone.conf");
[my-s3]
type = s3
provider = AWS
access_key_id = your_access_key
secret_access_key = your_secret_key
region = us-east-1[my-gdrive]
type = drive
client_id = your_client_id
client_secret = your_client_secret
token = your_tokenSecurity Note: Never commit sensitive credentials to version control. Use environment variables or a secrets manager for production environments.