{"id":16863807,"url":"https://github.com/nazar-pc/btrfs-sync-subvolumes","last_synced_at":"2025-04-11T08:59:35.415Z","repository":{"id":57024229,"uuid":"81257237","full_name":"nazar-pc/btrfs-sync-subvolumes","owner":"nazar-pc","description":"This is a pretty naive implementation of replication exact set of subvolumes from one location to another, plays nicely with Just backup btrfs","archived":false,"fork":false,"pushed_at":"2018-01-09T22:12:12.000Z","size":6,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T02:14:19.013Z","etag":null,"topics":["backup","btrfs","cli","copy","snapshot","subvolume","sync","synchronization"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nazar-pc.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-07T21:41:11.000Z","updated_at":"2021-03-16T15:24:29.000Z","dependencies_parsed_at":"2022-08-23T14:20:09.645Z","dependency_job_id":null,"html_url":"https://github.com/nazar-pc/btrfs-sync-subvolumes","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fbtrfs-sync-subvolumes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fbtrfs-sync-subvolumes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fbtrfs-sync-subvolumes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazar-pc%2Fbtrfs-sync-subvolumes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nazar-pc","download_url":"https://codeload.github.com/nazar-pc/btrfs-sync-subvolumes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248363670,"owners_count":21091414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","btrfs","cli","copy","snapshot","subvolume","sync","synchronization"],"created_at":"2024-10-13T14:39:49.882Z","updated_at":"2025-04-11T08:59:35.388Z","avatar_url":"https://github.com/nazar-pc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Btrfs sync subvolumes\nThis is a pretty naive implementation of replication exact set of subvolumes from one location to another, plays nicely with Just backup btrfs.\n\n### Why?\nMy 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.\n\nHowever, 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.\n\n### Requirements\n* php-cli (version 5.6+)\n\n### Installation\nThe whole thing is a single file, so first way is just to copy file `btrfs-sync-subvolumes` somewhere.\n\nAlternatively you can install it globally using Composer like this:\n```bash\nsudo COMPOSER_BIN_DIR=/usr/local/bin composer global require nazar-pc/btrfs-sync-subvolumes\n```\n`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.\nAlternatively you can skip it and add `~/.composer/vendor/bin/` to your PATH.\n\n### Removal\nIf installed manually - just remove file, if installed with Composer - remove it with:\n```bash\nsudo COMPOSER_BIN_DIR=/usr/local/bin composer global remove nazar-pc/btrfs-sync-subvolumes\n```\nOr without `COMPOSER_BIN_DIR=/usr/local/bin` if you didn't use it during installation.\n\n### Usage\n```\nUsage:\n  php btrfs-sync-subvolumes /source/directory /target/directory\n\nIt will scan /source/directory for directories and will copy each subvolume to /target/directory.\nSo, /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).\nAs 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.\nSubvolumes from /target/directory that do not exist in /source/directory will be removed.\n\nNOTE: Important assumptions:\n  - all directories found in /source/directory are subvolumes (no real check exists)\n  - each next subvolume (as listed by filesystem) is based on previous, otherwise instead of binary diff the whole subvolume will be copied\n```\n\nThere are few ways to run script.\n```bash\nsudo php btrfs-sync-subvolumes\n```\n\nor mark file as executable and just\n```bash\nsudo ./btrfs-sync-subvolumes\n```\n\nAlso you can call it with cron or in some other way:)\n\n### What it actually does?\n* treats each directory inside `/source/directory` as subvolume\n* checks whether same subvolume is present in `/target/directory`, if it exists - skips subvolume\n* for each next subvolume tries to send it as binary diff from previous subvolume\n* if it is the first subvolume or copying using diff fails - copies full subvolume\n* 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)\n\n### Configuration\nThere is no configuration or options, feel free to customize script for your needs.\n\n### License\nMIT, feel free to hack it and share!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazar-pc%2Fbtrfs-sync-subvolumes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnazar-pc%2Fbtrfs-sync-subvolumes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazar-pc%2Fbtrfs-sync-subvolumes/lists"}