Borg Server Script
Here’s the documentation for the provided shell script in Markdown format:
Borg Backup Server Script
This shell script acts as a server-side script to serve Borg Backup repositories using the BorgBackup tool. The script sets up a temporary directory, logs execution, and serves the specified Borg Backup repository. It is intended to be invoked remotely to allow authorized hosts to access and manage their respective backup repositories.
Script Features
- Sets the
TMPDIRenvironment variable to a temporary directory. - Logs execution details using the system logger.
- Creates a directory for the specific backup repository.
- Initiates the Borg Backup server to serve the repository.
Script Usage
- Configure SSH access and authentication between the client machines and the machine running this script.
- Modify the
borg_backup_locationvariable to point to the base directory where the individual backup repositories will be stored. - Invoke this script remotely on the backup server with the desired repository name as an argument.
Script Details
Environment Setup
This section sets up the
TMPDIRenvironment variable to a temporary directory within the user’s home directory.export TMPDIR=$HOME/tmpExecution Logging
This section logs the execution of the script along with the current date and the repository name.
logger "$0 executed at `date` for $1"Repository Creation
This section creates a directory for the specific backup repository within the configured base directory.
mkdir -p "{{ borg_backup_location }}/$1"Borg Backup Server
This section starts the Borg Backup server, restricting it to serve only the specified repository.
/usr/local/bin/borg serve --restrict-to-repository "{{ borg_backup_location }}/$1"
This script facilitates the setup of a Borg Backup server, allowing authorized clients to access their designated backup repositories. By configuring the script with the appropriate backup location and invoking it with the desired repository name, you can enable secure and controlled backup repository access for remote hosts.