Skip to content

fathzer/rclone-sync4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rclone-sync4j

Maven Central License Javadocs SonarCloud

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.

Features

  • Fluent API for configuring and running rclone sync operations
  • Real-time progress tracking
  • Support for checksum verification
  • File exclusion patterns support

Requirements

  • Java 17 or higher
  • rclone installed and available in system PATH

Installation

Maven

<dependency>
    <groupId>com.fathzer</groupId>
    <artifactId>rclone-sync4j</artifactId>
    <version>0.0.1</version>
</dependency>

Gradle

implementation 'com.fathzer:rclone-sync4j:0.0.1'

Usage

Basic Example

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);

Rclone Configuration

When rclone is already configured

If you already have rclone configured on your machine, the library will use your existing configuration file, typically located at:

  • ~/.config/rclone/rclone.conf on Linux/macOS
  • %APPDATA%\rclone\rclone.conf on Windows

When rclone is not configured

If rclone is not configured on the machine, you have two options:

  1. 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
  2. Use a custom config file location with withConfigFile:

    RcloneSync sync = new RcloneSync("source", "remote:path")
        .withConfigFile("/path/to/your/rclone.conf");

Remote Configuration Examples

S3 Example

[my-s3]
type = s3
provider = AWS
access_key_id = your_access_key
secret_access_key = your_secret_key
region = us-east-1

Google Drive Example

[my-gdrive]
type = drive
client_id = your_client_id
client_secret = your_client_secret
token = your_token

Security Note: Never commit sensitive credentials to version control. Use environment variables or a secrets manager for production environments.

About

A java facade for rclone sync, with progress support

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages