withaspark / backblaze-sync
A script for syncing files to Backblaze B2.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
This package is auto-updated.
Last update: 2025-04-10 05:11:15 UTC
README
Install
- Install B2 CLI following these instructions.
- Authorize B2 CLI.
- Login to Backblaze UI.
- Visit buckets page and create new application key (or use existing).
- Get values of
applicationKeyId
andapplicationKey
from thekeyId
and displayed value, respectively. - In terminal, authorize account by substituting for
applicationKeyId
andapplicationKey
.b2 authorize-account <applicationKeyId> <applicationKey>
- Install package.
composer require withaspark/BackblazeSync
Usage
CLI
path/to/backblaze_sync.php [-d|--dir <directory1> [-d|--dir <directory2> [...]]] <bucket>
Code
require __DIR__ . '/vendor/autoload.php'; $b2 = new withaspark\BackblazeSync\BackblazeSync($bucket, $local_dirs); $existing = $b2->getExistingFiles(); // Get all files currently in bucket $files = $b2->getFilesInDir(); // Get all files in local directory $b2->deleteDuplicateRemoteFiles(); // Delete duplicate files in bucket foreach ($files as $file) { $b2->upload($file); // Upload files if new } $b2->getUploadedCount(); // Get number of local files uploaded to B2 this run $b2->getDeletedCount(); // Get number of remote files deleted from B2 this run