Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active March 10, 2020 16:27
Show Gist options
  • Select an option

  • Save raphink/fe24bf6bc1205633471432f02ec13c15 to your computer and use it in GitHub Desktop.

Select an option

Save raphink/fe24bf6bc1205633471432f02ec13c15 to your computer and use it in GitHub Desktop.

Revisions

  1. raphink revised this gist Mar 10, 2020. 3 changed files with 99 additions and 0 deletions.
    47 changes: 47 additions & 0 deletions bivac-backup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    $ bivac backup ssh_config
    Backing up `ssh_config'...
    ID: ssh_config
    Name: ssh_sshconfig
    Mountpoint: /etc/ssh
    Backup date: 2019-06-13 09:35:38
    Backup status: Success
    Logs:
    testInit
    init
    backup [0]
    Files: 0 new, 0 changed, 11 unmodified
    Dirs: 0 new, 1 changed, 0 unmodified
    Added to the repo: 702 B
    processed 11 files, 299.375 KiB in 0:01
    snapshot 1c21ee5b saved
    forget [0] Applying Policy: keep the last 15 daily snapshots
    snapshots for (host [testing]):
    keep 15 snapshots:
    ID Time Host Tags Reasons Paths
    --------------------------------------------------------------------------------------------------------------
    1c21ee5b 2019-06-13 09:35:32 testing daily snapshot /etc/ssh
    --------------------------------------------------------------------------------------------------------------
    1 snapshots
    repository contains 18 packs (44 blobs) with 317.585 KiB
    processed 44 blobs: 0 duplicate blobs, 0B duplicate
    load all snapshots
    find data that is still in use for 15 snapshots
    [0:00] 100.00% 15 / 15 snapshots
    found 42 of 44 data blobs still in use, removing 2 blobs
    will remove 0 invalid files
    will delete 1 packs and rewrite 0 packs, this frees 763B
    counting files in repo
    [0:00] 100.00% 17 / 17 packs
    finding old index files
    saved new indexes as [f027febd]
    remove 2 old index files
    [0:00] 100.00% 1 / 1 packs deleted
    done
    48 changes: 48 additions & 0 deletions bivac-restore.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    $ bivac restore canary
    Restoring `canary'...
    ID: canary
    Name: canary
    Mountpoint: /var/lib/docker/volumes/canary/_data
    Backup date: 2019-06-13 07:56:36
    Backup status: Success
    Logs:
    restore [0] restoring <Snapshot 15583d4b of [/var/lib/docker/volumes/canary/_data] at 2019-06-13 07:56:13.905600644 +0000 UTC by root@testing> to /var/lib/docker/volumes/canary/_data/h3bf5TfCxKtisKYF
    snapshots [0] [{"time":"2019-06-13T07:56:13.905600644Z","tree":"e6790a6cf2fd100d01b3bcac795c8787411b0879c85d60514f109403d26890bf","paths":["/var/lib/docker/volumes/canary/_data"],"hostname":"testing","username":"root","id":"15583d4b11605ec552be08fd1fd76d7549aefa0104ab4111f629737d5c7f7a17","short_id":"15583d4b"}]
    Manage a remote Restic repository
    If you want to list volume's snapshots or retrieve some stats, you will have to use Restic and Bivac provides a good abstraction to do it.
    Let's say you have volume called canary and you want to list the associate snapshots, then you'll simply run:
    $ bivac restic --volume canary snapshots
    ID Time Host Tags Paths
    -------------------------------------------------------------------------------------------
    9d22678e 2019-01-13 03:35:01 canary /mnt/geoserver_geodata
    -------------------------------------------------------------------------------------------
    1 snapshots
    In case, you'd like to run a more complex command, you must use -- as follow:
    $ bivac restic --volume canary -- forget --prune --keep-daily 15
    Troubleshooting
    My backup failed because the remote repository is locked.
    The first thing to do is to check the date and the user who created the lock. From these informations, you should be able to determine if the lock is "legit" (a backup is running) or if it's a remnant of a forgotten backup. If you think it's safe to remove it, then you can run:
    $ bivac backup [VOLUME_ID] --force
    With the option --force, Bivac will unlock the Restic repository before doing a backup.
    Add a custom footer
    Pages 5
    Overview
    Installation
    Docker
    Rancher (Cattle)
    Kubernetes
    Usage
    Backup a volume
    Restore a volume
    Manage a remote Restic repository
    Troubleshooting
    Providers
    Monitoring
    API
    Clone this wiki locally
    4 changes: 4 additions & 0 deletions bivac-volumes.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    $ bivac volumes
    ID Name Hostname Mountpoint LastBackupDate LastBackupStatus Backing up
    mysql mysql testing /var/lib/mysql 2019-06-13 01:33:44 Success false
    ssh_config ssh_config testing /etc/ssh 2019-06-13 01:43:12 Success false
  2. raphink revised this gist Mar 10, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions helm.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    $ helm repo add camptocamp http://charts.camptocamp.com
    $ helm install camptocamp/bivac --version 1.0.0
  3. raphink created this gist Mar 10, 2020.
    17 changes: 17 additions & 0 deletions docker-compose.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    ---
    version: '3'
    services:
    bivac:
    image: camptocamp/bivac:2.2
    command: "manager -v"
    ports:
    - "8182:8182"
    volumes:
    - "/var/run/docker.sock:/var/run/docker.sock:ro"
    environment:
    BIVAC_AGENT_IMAGE: camptocamp/bivac:2.1
    BIVAC_SERVER_PSK: super-secret-psk
    RESTIC_PASSWORD: not-so-good-password
    BIVAC_TARGET_URL: s3:my-bucket
    AWS_ACCESS_KEY_ID: XXXXX
    AWS_SECRET_ACCESS_KEY: XXXXX