Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a prototype example docker-compose environment. #239

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Here's a simple example of running this in a docker-compose environment.

Read through `docker-compose.yml` and change things as appropriate. Then do the same with `borgmatic.d/config.yml` and `borgmatic.d/crontab.txt`.

Start the container - `docker-compose up -d`.

At the moment, you need to initialize the repo manually. Connect to the container directly (`docker exec -it borgmatic bash`). If you want a repo without encryption, run `borgmatic init -e none`.

If you are using encryption, you'll need to do something else; I haven't written this section because I'm not using encryption (sorry! Please file a pull request if you figure it out!) Also, IT IS VITALLY IMPORTANT THAT YOU BACK UP `/config.borg/*` AND YOUR PASSPHRASE TO SOMEPLACE SAFE. YOU WILL NEED THESE TO RESTORE YOUR BACKUP. THIS IS NOT OPTIONAL.
46 changes: 46 additions & 0 deletions example/borgmatic.d/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See https://torsion.org/borgmatic/docs/reference/configuration/ for detailed information.

location:
source_directories:
- /mnt/source
exclude_patterns:
# Common location for ephemeral cache files that don't need to be backed up.
- /mnt/source/home/*/.cache
source_directories_must_exist: true

repositories:
# If you're backing up to a local directory, use this.
- /mnt/borg-repository

# If you're backing up to a remote server, use your remote server's provided URL.
# This URL is an example provided by Borgbase and will not work for you, you'll need your own.
#- ssh://[email protected]/./repo

storage:
compression: lz4
archive_name_format: 'backup-{now}'

retention:
keep_hourly: 0
keep_daily: 7
keep_weekly: 4
keep_monthly: 12
keep_yearly: 1

consistency:
checks:
- repository
- archives
check_last: 3
prefix: 'backup-'

hooks:
before_backup:
- echo "Starting a backup job."
after_backup:
- echo "Backup created."
on_error:
- echo "Error while creating a backup."

# Third-party services to notify you if backups aren't happening; see https://healthchecks.io
# healthchecks: https://hc-ping.com/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2 changes: 2 additions & 0 deletions example/borgmatic.d/crontab.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## This starts a Borg run every day at 2 in the morning.
0 2 * * * PATH=$PATH:/usr/local/bin /usr/local/bin/borgmatic --stats -v 0 2>&1
56 changes: 56 additions & 0 deletions example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "2.4"
services:
borgmatic:
container_name: borgmatic

image: ghcr.io/borgmatic-collective/borgmatic
#build: ../base

volumes:
# -------------
# Source and destination directories

# Mount the directories you want to back up under /mnt/source.
# Common suggestions are provided here.
# We're mounting them read-only for a little extra safety.
- /home:/mnt/source/home:ro # User home directories.
- /etc:/mnt/source/etc:ro # System configuration.
#- /var:/mnt/source/var:ro # Variable system data; it's common for databases and Docker volumes to end up here. Probably not necessary unless you're hosting services off this computer.
#- /srv:/mnt/source/srv:ro # Another common location for service data, especially websites.
#- /media:/mnt/source/media:ro # Common location for mounted external drives or secondary drives. Likely to include USB sticks and CDs, which may be undesirable.
#- /data:/mnt/source/data:ro # Less standard but sometimes-seen directory for permanent drive mounts and service data.

# If you're backing up to a local backup destination, mount it here.
# Remove this if you're doing remote backups only.
- /mnt/backup:/mnt/borg-repository

# -------------
# Config files that you write

# Borgmatic and crontab config files will go here.
- ./borgmatic.d:/etc/borgmatic.d/

# If you're using a remote repository, you'll need an SSH key.
# Uncomment this if you want to use root's ssh key.
#- ~/.ssh:/root/.ssh

# If you want a separate SSH key just for borg, uncomment this instead, then `ssh-keygen -f ssh/id_rsa`.
#- ./ssh:/root/.ssh

zorbathut marked this conversation as resolved.
Show resolved Hide resolved
# -------------
# Borgmon working space

# Borgmon will write config files and keyfiles here (if you're using encryption, back these up somewhere very safe! You will need them to restore your backup! If you do not have your keyfile you will not be able to restore encrypted files!)
- ./config.borg:/root/.config/borg

# Borg wants local cache data to track deduplication. Does not need to be backed up, but makes Borg run faster.
- ./cache.borg:/root/.cache/borg

environment:
# Change this to your local timezone if you care about when your backups run.
- TZ=America/Chicago

# If you're using a passphrase on your keyfile, make sure this is wrtten somewhere extremely safe. You will also need this to restore your files!
#- BORG_PASSPHRASE=SetYourPassphraseHereIfYouWantOne

restart: unless-stopped