Docker container that uses Borg and rclone to create backups deployed in Google Cloud Storage.
- A Google account with a GCP project (billing must be enabled)
gcloud
CLI to configure your GCP authenticationterraform
to provision the required resources on GCPdocker
to build and run the backup container
Before using this project, you have to configure your GCP authentication using gcloud
CLI:
gcloud auth application-default login
Create a .auto.tfvars
file inside provision/
directory with the following variables set:
google_project_id = "<GCP_PROJECT_ID>"
google_region = "<GCP_REGION>"
google_zone = "<GCP_ZONE>"
Initialize Terraform locally and start the provisioning:
cd provision
terraform init
terraform apply
Once the provision ends, you can re-initialize Terraform to move the global state in your newly created buckets. To do that,
configure your backend by creating a .gcs.tfbackend
file inside provision/
directory with the following variables set:
bucket = "<YOUR_BUCKET_NAME>"
prefix = "terraform/state"
Then, re-initialize Terraform to move the state on Google Cloud Storage:
terraform init -backend-config=.gcs.tfbackend
To boostrap your environment, launch the following commands from the repository folder:
mkdir -p config/
mkdir -p cache/
cp env.example .env
chmod 600 .env
Docker Compose uses automatically the .env
file. You must update included values as follows:
DATA_PATH
: is the folder you want to backup. Example:/home/user/Pictures
.BORG_PASSPHRASE
: is the key used to encrypt Borg repository. Check Borg documentation for more details.RCLONE_REMOTE_PATH
: is the remote storage path inrcloud
format. Example:REMOTE_NAME:BUCKET_NAME
.CROND_SCHEDULE
: is the schedule used bycrond
to execute the backup. Example:0 2 * * *
(every day at 2 AM).
Once the configuration is done, you can run the container as a service that will execute the backup based
on the CROND_SCHEDULE
. If the backup is not initialized, the container will create a new repository in the
rclone
mount folder.
To run the container as a service, use the following command:
docker compose up -d
To extract the backup archive you must stop any running container. Once the container is stopped, you can use the following helper:
docker compose run --rm -ti backup extract.sh
We accept external contributions even though the project is mostly designed for personal needs. If you think some parts can be exposed with a more generic interface, feel free to open a GitHub issue to discuss your suggestion.