#file #sync #cloudflare #local #r2 #directory #bucket

app r2sync

cli for synchronizing files between a local directory and Cloudflare R2

4 releases

0.0.4 Oct 15, 2024
0.0.3 Oct 14, 2024
0.0.2 Oct 14, 2024
0.0.1 Oct 13, 2024

#317 in Network programming

Download history 402/week @ 2024-10-09 76/week @ 2024-10-16

147 downloads per month

MIT license

37KB
992 lines

r2sync

Test Status License Crates.io Documentation

r2sync is a command-line tool for synchronizing files between a local directory and Cloudflare R2. It allows seamless syncing of files to and from your R2 bucket.

Features

  • Sync local directories with Cloudflare R2 buckets.
  • For efficient sync, look at the eTag and content length of the remote file and skip the put appropriately.

Installation

$ brew install Songmu/tap/r2sync

You can build and install the latest version from the source code. Ensure you have Rust installed, and then run:

$ cargo install r2sync

Alternatively, you can clone the repository and build the project locally:

$ git clone https://github.com/Songmu/r2sync.git
$ cd r2sync
$ cargo build --release

Usage

Once installed, you can start syncing files by using the r2sync command.

Basic Usage

r2sync ./localdir r2://bucket.example.com/dir

This will sync the contents of ./localdir to the R2 bucket at r2://bucket.example.com/dir.

Syncing from R2 to Local Directory

To sync files from R2 to a local directory:

r2sync r2://bucket.example.com/dir ./localdir

Full Command Line Options

  • --public-domain: If a public domain is specified, the remote content is checked before the file is put out, and if it is identical, the put is skipped.

Configuration

You can provide authentication details via environment variables.

Environment Variables

export R2_ACCOUNT_ID=<your-account-id>
export R2_ACCESS_KEY_ID=<your-access-key>
export R2_SECRET_ACCESS_KEY=<your-secret-key>

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

Contact

For any questions or issues, feel free to open an issue on the GitHub repository or reach out via email at y.songmu@gmail.com.

Dependencies

~25–37MB
~502K SLoC