Go to file
Urko. 1303d540cb fix: copy file with long long running ctx 2024-01-01 15:01:51 +01:00
cmd fix: sync create longRunningCtx 2023-12-26 16:44:37 +01:00
internal/services fix: copy file with long long running ctx 2024-01-01 15:01:51 +01:00
kit fix: change From to MailFrom 2023-08-28 08:51:02 +02:00
.gitignore refactor: whole application 2023-08-27 21:30:19 +02:00
License fix: count 2023-08-28 11:18:50 +02:00
Makefile feat: handle list for repeated files/versions 2023-07-18 14:23:33 +02:00
Readme.md feat: update README 2023-08-27 21:47:13 +02:00
go.mod feat: upgrade go version 2023-12-26 16:47:04 +01:00
go.sum fix: mod tidy 2023-12-26 16:47:36 +01:00
main.go refactor: paremeterize max workers 2023-10-01 14:35:50 +02:00

Readme.md

Backblaze Backup Tool

This is a tool to backup files and directories to Backblaze.

Prerequisites

  • Go 1.16 or higher
  • Backblaze account with a bucket created
  • Environment variables BB_ID and BB_KEY set with your Backblaze account ID and application key respectively

Building the Application

You can build the application using the provided Makefile.

On Linux:

make rebuild

On Windows:

You will need to have make installed. If you don't have it, you can install it through Chocolatey:

choco install make

Then you can run the same command as on Linux:

make rebuild

This will create a binary in the bin directory.

Running the Application

You can run the application directly from the command line. Here's how to do it:

./bin/backblaze-backup sync --bucket "your-bucket-name" --dir "/path/to/directory"

Or if you want to upload a single file:

./bin/backblaze-backup sync --bucket "your-bucket-name" --file "/path/to/file"

You can also use the local_run command in the Makefile to run the application with a test directory and bucket:

make local_run DIR="/home/user/test-upload" BUCKET="my-test-bucket"

This will run the application with the directory /home/user/test-upload and the bucket my-test-bucket.

Flags

--bucket: The name of your Backblaze bucket
--dir: The absolute path of the directory you want to upload to Backblaze
--file: The absolute path of the file you want to upload to Backblaze

Note: You must select just one option, dir or file.

Please replace "your-bucket-name", "/path/to/directory", and "/path/to/file" with your actual bucket name and paths.

Environment Variables

The application uses the following environment variables:

  • BB_ID: Your Backblaze account ID
  • BB_KEY: Your Backblaze application key
  • LOG_LEVEL: Sets the log level (DEBUG, INFO, WARN, ERROR). Default is INFO.

You can set these variables in your environment, or you can use a .env file in the root directory of the project. If the BACKBLAZE_ENV environment variable is set to dev, the application will load the .env file.

Configurable Logging

The application supports configurable logging levels. Set the LOG_LEVEL environment variable to one of the following values:

  • DEBUG: Detailed debug information
  • INFO: Informational messages
  • WARN: Warnings
  • ERROR: Errors only

Syncing with Backblaze

The application uses the Sync method of the BackBlaze service to sync files or directories to Backblaze. If there's an error during the sync, the application will log the error and exit.

./bin/backblaze-backup sync

Checking for Duplicate Versions

The application can also check for duplicate versions of files in your Backblaze buckets. To do this, run the following command:

./bin/backblaze-backup versions

If there are any duplicate versions, the application will log them and exit.

Cleaning Up Duplicate Versions

The application can also clean up duplicate versions of files in your Backblaze buckets. To do this, run the following command:

./bin/backblaze-backup cleanup

If there are any errors during the cleanup, the application will log them and exit.

Check discrepancy between local backup and B2

The application can also check that all local files has been backed up into B2 cloud. To do this, run the following command:

./bin/backblaze-backup check --dir "/var/tmp/test-upload" --bucket "b2-bucket"

If there are any errors during the check, the application will log them and exit.