Library

Sending backups from HQbird to Amazon S3

In order to send backups created by HQbird to Amazon S3, the easiest way will be to use Amazom CLI (command-line interface).
Use the post-backup script functionality (see "Execute shell command" here), available in HQbird: specify command-file which receives the path to the created backup as the first parameter.

The example of the command file for Windows:

@echo off
setlocal EnableDelayedExpansion

:: S3 Configuration - Replace these with your actual values
set "AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_HERE"
set "AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY_HERE"
set "S3_BUCKET=your-bucket-name"
set "S3_REGION=us-east-1"

:: Check if a file path was provided
if "%~1"=="" (
    echo Error: Please provide the path to the file you want to upload.
    echo Usage: %0 [file_path]
    exit /b 1
)

:: Check if the file exists
if not exist "%~1" (
    echo Error: File not found: %~1
    exit /b 1
)

:: Get just the filename from the path
for %%F in ("%~1") do set "FILE_NAME=%%~nxF"

echo Uploading %FILE_NAME% to S3 bucket %S3_BUCKET%...

:: Check if AWS CLI is installed
where aws >nul 2>&1
if %ERRORLEVEL% neq 0 (
    echo Error: AWS CLI is not installed or not in the PATH.
    echo Please install AWS CLI from https://aws.amazon.com/cli/
    exit /b 1
)

:: Set AWS credentials for this session
set "AWS_ACCESS_KEY_ID=%AWS_ACCESS_KEY_ID%"
set "AWS_SECRET_ACCESS_KEY=%AWS_SECRET_ACCESS_KEY%"
set "AWS_DEFAULT_REGION=%S3_REGION%"

:: Upload file to S3
aws s3 cp "%~1" "s3://%S3_BUCKET%/%FILE_NAME%" --region %S3_REGION%

if %ERRORLEVEL% equ 0 (
    echo Upload successful!
    echo File available at: https://%S3_BUCKET%.s3.%S3_REGION%.amazonaws.com/%FILE_NAME%
) else (
    echo Upload failed with error code %ERRORLEVEL%
)

endlocal
exit /b