Backup Files
Backs up local files to Backblaze B2 using rclone.
Arguments
$0: (optional) local path to back up$1: (optional) destination subfolder within the bucket
Default Bucket
The default destination bucket is b2:czue-youtube-backups.
Important: --max-depth
By default, always use --max-depth 1 to avoid recursing into subdirectories. rclone will crawl the entire directory tree otherwise, which can be very slow and pick up unrelated files. Only omit --max-depth if the user explicitly asks to include subdirectories.
Workflow
-
Resolve the source path:
- If
$0is provided, use it. - Otherwise, use
AskUserQuestionto ask what to back up, with these options:~/Videos/- Video files~/Music/- Music files~/Documents/- Documents
- Verify the source path exists before proceeding.
- If
-
Resolve the destination path:
- If
$1is provided, useb2:czue-youtube-backups/$1as the destination. - Otherwise, use
AskUserQuestionto ask for the destination subfolder within the bucket, suggesting a sensible default based on the source path (e.g.~/Videos/→videos,~/Documents/→documents).
- If
-
Determine depth:
- Default to
--max-depth 1(no subdirectory traversal). - If the user explicitly requests recursive/subdirectory backup, omit
--max-depth.
- Default to
-
Show what will be backed up:
- Run
du -sh <source>to show the total size. - Run a dry run first so the user can see what will happen:
rclone copy <source> b2:czue-youtube-backups/<dest> --max-depth 1 --dry-run - Show the user a summary and ask for confirmation before proceeding.
- Run
-
Run the backup:
rclone copy <source> b2:czue-youtube-backups/<dest> --max-depth 1 --progress --stats=5sRun this in the foreground so the user can see progress.
-
Report results: Summarize what was backed up and the destination.
