{"id":50488036,"url":"https://github.com/yamatt/b2mv","last_synced_at":"2026-06-02T00:03:55.116Z","repository":{"id":319463838,"uuid":"1078755573","full_name":"yamatt/b2mv","owner":"yamatt","description":"A script that helps you move files within Backblaze B2","archived":false,"fork":false,"pushed_at":"2025-10-18T11:43:02.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-19T06:58:33.820Z","etag":null,"topics":["backblaze-b2","bash"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yamatt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-18T11:00:41.000Z","updated_at":"2025-10-18T11:43:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"67caedbf-0d92-4d27-b188-c3d103a97b76","html_url":"https://github.com/yamatt/b2mv","commit_stats":null,"previous_names":["yamatt/b2mv"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/yamatt/b2mv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamatt%2Fb2mv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamatt%2Fb2mv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamatt%2Fb2mv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamatt%2Fb2mv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yamatt","download_url":"https://codeload.github.com/yamatt/b2mv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamatt%2Fb2mv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33798943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["backblaze-b2","bash"],"created_at":"2026-06-02T00:03:53.027Z","updated_at":"2026-06-02T00:03:55.110Z","avatar_url":"https://github.com/yamatt.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# b2mv\n\nA simple command-line utility for moving and renaming files and directories in Backblaze B2 cloud storage.\n\n## Description\n\n`b2mv` provides a convenient way to move or rename files and entire directories within Backblaze B2 buckets using server-side operations. It performs server-side copy followed by deletion of the original files, similar to how the `mv` command works in Unix-like systems.\n\n## Features\n\n- **Single file operations**: Move or rename individual files\n- **Directory operations**: Move entire directories with all their contents\n- **Server-side operations**: Efficient transfers without downloading/uploading\n- **Progress tracking**: Shows progress when moving multiple files\n- **Error handling**: Robust error handling with clear messages\n\n## Prerequisites\n\n- [Backblaze B2 CLI](https://www.backblaze.com/b2/docs/tool_installation.html) must be installed and configured\n- Valid B2 account credentials configured via `b2 authorize-account`\n\n## Installation\n\n1. Make the script executable:\n\n   ```bash\n   chmod +x b2mv\n   ```\n\n2. Optionally, move it to a directory in your PATH:\n   ```bash\n   sudo mv b2mv /usr/local/bin/\n   ```\n\n## Usage\n\n```bash\nb2mv \u003cbucket\u003e \u003cold-path\u003e \u003cnew-path\u003e\n```\n\n### Parameters\n\n- `bucket`: The name of the B2 bucket containing the files\n- `old-path`: The current path/name of the file or directory in the bucket\n- `new-path`: The new path/name for the file or directory in the same bucket\n\n**Important**: Use trailing slashes (`/`) for directory operations.\n\n### Examples\n\n**Rename a single file:**\n\n```bash\nb2mv my-bucket old-name.txt new-name.txt\n```\n\n**Move a file to a different directory within the same bucket:**\n\n```bash\nb2mv my-bucket file.txt archive/file.txt\n```\n\n**Move an entire directory:**\n\n```bash\nb2mv my-bucket old-directory/ new-directory/\n```\n\n**Move a directory to a new location:**\n\n```bash\nb2mv my-bucket documents/ archive/2023/documents/\n```\n\n**Rename and move simultaneously:**\n\n```bash\nb2mv my-bucket documents/report.pdf backups/2023/annual-report.pdf\n```\n\n**Reorganize directory structure:**\n\n```bash\nb2mv my-bucket temp-uploads/ processed/batch-2023-10/\n```\n\n## How It Works\n\n### Single File Operations\n\nFor single files, the script performs two operations:\n\n1. **Server-side copy**: Creates a copy of the file at the new location using `b2 file server-side-copy`\n2. **Delete original**: Removes the original file using `b2 rm`\n\n### Directory Operations\n\nFor directories (indicated by trailing slash), the script:\n\n1. **Lists all files**: Uses `b2 ls --recursive` to find all files in the source directory\n2. **Processes each file**: Iterates through each file and performs the move operation\n3. **Progress tracking**: Shows current progress (file X of Y)\n4. **Preserves structure**: Maintains the relative directory structure in the destination\n\n## Directory Operation Details\n\n- **Detection**: Directory operations are detected by a trailing slash (`/`) in the source path\n- **Recursive**: All files and subdirectories are moved recursively\n- **Structure preservation**: The relative path structure is maintained in the destination\n- **Progress feedback**: Shows which file is being processed and overall progress\n- **Error handling**: If any file fails to move, the operation stops with an error\n\n## Error Handling\n\nThe script includes comprehensive error handling to:\n\n- Validate that exactly 3 arguments are provided\n- Exit immediately if any command fails (due to `set -euo pipefail`)\n- Handle copy failures without removing the original file\n- Provide clear error messages for debugging\n- Track progress and show which operations succeed or fail\n\n## Performance Considerations\n\n- **Server-side operations**: All copy operations happen on Backblaze servers\n- **No data transfer**: Files are not downloaded/uploaded, saving bandwidth and time\n- **Sequential processing**: Files are moved one at a time to avoid overwhelming the API\n- **Data transfer costs**: Server-side copy operations within the same region are typically free\n\n## Notes\n\n- **Atomic operation**: If a copy fails, the original file remains untouched\n- **File metadata**: Server-side copy preserves file metadata including timestamps and custom headers\n- **Directory syntax**: Always use trailing slashes for directory operations\n- **Large directories**: For very large directories, the operation may take some time but will show progress\n\n## License\n\nSee the LICENSE file for details.\n\n## Contributing\n\nFeel free to submit issues and pull requests to improve this utility.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamatt%2Fb2mv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamatt%2Fb2mv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamatt%2Fb2mv/lists"}