diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..c320a7d --- /dev/null +++ b/example/README.md @@ -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. \ No newline at end of file diff --git a/example/borgmatic.d/config.yml b/example/borgmatic.d/config.yml new file mode 100644 index 0000000..38496da --- /dev/null +++ b/example/borgmatic.d/config.yml @@ -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://mmvz9gp4@mmvz9gp4.repo.borgbase.com/./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 diff --git a/example/borgmatic.d/crontab.txt b/example/borgmatic.d/crontab.txt new file mode 100644 index 0000000..abf82ef --- /dev/null +++ b/example/borgmatic.d/crontab.txt @@ -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 diff --git a/example/docker-compose.yml b/example/docker-compose.yml new file mode 100644 index 0000000..7ae6e82 --- /dev/null +++ b/example/docker-compose.yml @@ -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 + + # ------------- + # 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