准备步骤

先注册账号

https://www.backblaze.com/

1.安装b2命令

wget https://github.com/Backblaze/B2_Command_Line_Tool/releases/latest/download/b2-linux

# 授权

chmod +x b2-linux

# 重命名

mv b2-linux b2

#  添加path

mv b2 /usr/bin

2.安装7z

sudo apt update

sudo apt install p7zip-full

3 使用如下命令进行b2授权

b2 account authorize xxxxx xxxxx

授权ID与KEY的生成

20240905110751.png

在宝塔或者1panel添加如下定时执行脚本

#!/bin/bash

# 设置 Backblaze B2 存储桶名称

B2_BUCKET_NAME="xxxx"

# 设置备份路径和文件名  1panel默认挂载路径

BACKUP_PATH="/opt/1panel/apps/bitwarden/bitwarden/data"

BACKUP_FILE="bitwarden_backup_$(date +%Y-%m-%d_%H-%M-%S).zip"

# 设置压缩包密码

BACKUP_PASSWORD="xxxxx"

# 打包压缩文件并设置密码

7z a -tzip -p"$BACKUP_PASSWORD" "$BACKUP_FILE" "$BACKUP_PATH"

# 上传备份文件到 B2 存储桶

b2 upload-file "$B2_BUCKET_NAME" "$BACKUP_FILE" "$BACKUP_FILE"

# 删除本地备份文件 (可选)

rm "$BACKUP_FILE"

echo "Bitwarden backup uploaded to Backblaze B2 successfully!"