PHPackages                             nazar-pc/btrfs-sync-subvolumes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. nazar-pc/btrfs-sync-subvolumes

ActiveLibrary[CLI &amp; Console](/categories/cli)

nazar-pc/btrfs-sync-subvolumes
==============================

This is a pretty naive implementation of replication exact set of subvolumes from one location to another, plays nicely with Just backup btrfs.

0.3.0(9y ago)717[1 PRs](https://github.com/nazar-pc/btrfs-sync-subvolumes/pulls)MITPHPPHP &gt;=5.6

Since Feb 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/nazar-pc/btrfs-sync-subvolumes)[ Packagist](https://packagist.org/packages/nazar-pc/btrfs-sync-subvolumes)[ Docs](https://github.com/nazar-pc/btrfs-sync-subvolumes)[ RSS](/packages/nazar-pc-btrfs-sync-subvolumes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (4)Used By (0)

### Btrfs sync subvolumes

[](#btrfs-sync-subvolumes)

This is a pretty naive implementation of replication exact set of subvolumes from one location to another, plays nicely with Just backup btrfs.

### Why?

[](#why)

My primary use case is that I'm doing regular snapshots on SSD for my system drive (root, home, etc.) as well as copying them to external HDD, all done by [Just backup btrfs](https://github.com/nazar-pc/just-backup-btrfs) natively.

However, I also wanted to make offline backup from time to time and this project does just that, copying all snapshots from online HDD to offline HDD that I'm connecting from time to time.

### Requirements

[](#requirements)

- php-cli (version 5.6+)

### Installation

[](#installation)

The whole thing is a single file, so first way is just to copy file `btrfs-sync-subvolumes` somewhere.

Alternatively you can install it globally using Composer like this:

```
sudo COMPOSER_BIN_DIR=/usr/local/bin composer global require nazar-pc/btrfs-sync-subvolumes
```

`COMPOSER_BIN_DIR=/usr/local/bin` will instruct Composer to install binary to `/usr/local/bin` so that you'll be able to call `btrfs-sync-subvolumes` right after installation. Alternatively you can skip it and add `~/.composer/vendor/bin/` to your PATH.

### Removal

[](#removal)

If installed manually - just remove file, if installed with Composer - remove it with:

```
sudo COMPOSER_BIN_DIR=/usr/local/bin composer global remove nazar-pc/btrfs-sync-subvolumes
```

Or without `COMPOSER_BIN_DIR=/usr/local/bin` if you didn't use it during installation.

### Usage

[](#usage)

```
Usage:
  php btrfs-sync-subvolumes /source/directory /target/directory

It will scan /source/directory for directories and will copy each subvolume to /target/directory.
So, /source/directory/sub1 will be copied as /target/directory/sub1 and so on for each subvolume (binary diffs are used if possible in order to optimize transfer).
As the result it will replicate all subvolumes from /source/directory in /target/directory so that both directories will have the same list of identical subvolumes.
Subvolumes from /target/directory that do not exist in /source/directory will be removed.

NOTE: Important assumptions:
  - all directories found in /source/directory are subvolumes (no real check exists)
  - each next subvolume (as listed by filesystem) is based on previous, otherwise instead of binary diff the whole subvolume will be copied

```

There are few ways to run script.

```
sudo php btrfs-sync-subvolumes
```

or mark file as executable and just

```
sudo ./btrfs-sync-subvolumes
```

Also you can call it with cron or in some other way:)

### What it actually does?

[](#what-it-actually-does)

- treats each directory inside `/source/directory` as subvolume
- checks whether same subvolume is present in `/target/directory`, if it exists - skips subvolume
- for each next subvolume tries to send it as binary diff from previous subvolume
- if it is the first subvolume or copying using diff fails - copies full subvolume
- removes each subvolume from `/target/directory` that is not present in `/source/directory` (only if `/source/directory` is not empty, just in case something went wrong)

### Configuration

[](#configuration)

There is no configuration or options, feel free to customize script for your needs.

### License

[](#license)

MIT, feel free to hack it and share!

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Total

3

Last Release

3302d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/050c23d89354489e351eed5096aa585badd35d2bbe283218bbb8f2516534c513?d=identicon)[nazar-pc](/maintainers/nazar-pc)

---

Top Contributors

[![nazar-pc](https://avatars.githubusercontent.com/u/928965?v=4)](https://github.com/nazar-pc "nazar-pc (4 commits)")

---

Tags

backupbtrfsclicopysnapshotsubvolumesyncsynchronizationclifilesystemsnapshotbackupsynchronizationcopysyncbtrfssubvolume

### Embed Badge

![Health badge](/badges/nazar-pc-btrfs-sync-subvolumes/health.svg)

```
[![Health](https://phpackages.com/badges/nazar-pc-btrfs-sync-subvolumes/health.svg)](https://phpackages.com/packages/nazar-pc-btrfs-sync-subvolumes)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)[innoge/laravel-rclone

A sleek PHP wrapper around rclone with Laravel-style fluent API syntax

174.1k](/packages/innoge-laravel-rclone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
