forked from coop-cloud/backup-bot-two
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa5078eb6e | |||
| 3bbef4a0de | |||
| f3924969e8 | |||
| ff7c9c5cd8 | |||
| 25f977c312 | |||
| 6255edc834 | |||
| c17c3f0273 | |||
|
b1051c7a35
|
|||
|
c2cb524710
|
|||
| 1a617f0942 | |||
| dd85f389f4 | |||
| 4d7d8fc577 | |||
|
ef4f0ec87e
|
+3
-4
@@ -1,11 +1,10 @@
|
||||
FROM docker:24.0.7-dind
|
||||
FROM docker:29.4.3-dind
|
||||
|
||||
RUN apk add --upgrade --no-cache restic bash python3 py3-pip py3-click py3-docker-py py3-json-logger curl
|
||||
|
||||
# Todo use requirements file with specific versions
|
||||
RUN pip install --break-system-packages resticpy==1.0.2
|
||||
RUN pip install --break-system-packages resticpy==1.3.0
|
||||
|
||||
COPY backupbot.py /usr/bin/backup
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -79,7 +79,7 @@ Add the key to your `authorized_keys`:
|
||||
`ssh-copy-id -i backupkey <user>@<hostname>`
|
||||
Add your `SSH_KEY` as docker secret:
|
||||
```
|
||||
cat backupkey | app secret insert <backupbot_name> ssh_key v1
|
||||
cat backupkey | abra app secret insert <backupbot_name> ssh_key v1
|
||||
```
|
||||
|
||||
### Restic REST server Storage
|
||||
@@ -137,55 +137,57 @@ Enable basic auth in the env file, by uncommenting the following line:
|
||||
|
||||
## Usage
|
||||
|
||||
Run the cronjob that creates a backup, including the push notifications and docker logging:
|
||||
### Run the cronjob that creates a backup, including the push notifications and docker logging:
|
||||
|
||||
`abra app cmd <backupbot_name> app run_cron`
|
||||
|
||||
Create a backup of all apps:
|
||||
### Create a backup of all apps:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup create`
|
||||
|
||||
> The apps to backup up need to be deployed
|
||||
|
||||
Create an individual backup:
|
||||
### Create an individual backup:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup --host <target_app_name> create`
|
||||
|
||||
Create a backup to a local repository:
|
||||
### Create a backup to a local repository:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup create -r /backups/restic`
|
||||
|
||||
> It is recommended to shutdown/undeploy an app before restoring the data
|
||||
|
||||
Restore the latest snapshot of all including apps:
|
||||
### Restore the latest snapshot of all including apps:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup restore`
|
||||
|
||||
Restore a specific snapshot of an individual app:
|
||||
### Restore a specific snapshot of an individual app:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup --host <target_app_name> restore --snapshot <snapshot_id>`
|
||||
|
||||
Show all snapshots:
|
||||
### Show all snapshots:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup snapshots`
|
||||
|
||||
Show all snapshots containing a specific app:
|
||||
### Show all snapshots containing a specific app:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup --host <target_app_name> snapshots`
|
||||
|
||||
Show all files inside the latest snapshot (can be very verbose):
|
||||
### Show all files inside the latest snapshot (can be very verbose):
|
||||
|
||||
`abra app run <backupbot_name> app -- backup ls`
|
||||
|
||||
Show specific files inside a selected snapshot:
|
||||
### Show specific files inside a selected snapshot:
|
||||
|
||||
`abra app run <backupbot_name> app -- backup ls --snapshot <snapshot_id> /var/lib/docker/volumes/`
|
||||
|
||||
Download files from a snapshot:
|
||||
### Download files from a snapshot:
|
||||
|
||||
```
|
||||
filename=$(abra app run <backupbot_name> app -- backup download --snapshot <snapshot_id> --path <absolute_path>)
|
||||
abra app cp <backupbot_name> app:$filename .
|
||||
```
|
||||
`abra app run <backupbot_name> app -- backup download --snapshot <snapshot_id> --path <absolute_path>`
|
||||
|
||||
extract the <path> from the output of the first command and use in the second.
|
||||
|
||||
`abra app cp <backupbot_name> app:<path> .`
|
||||
|
||||
## Run restic
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export SSH_CONFIG_VERSION=v1
|
||||
export ENTRYPOINT_VERSION=v17
|
||||
export CRONJOB_VERSION=v2
|
||||
export CRONJOB_VERSION=v3
|
||||
|
||||
run_cron () {
|
||||
schedule="$(crontab -l | tr -s " " | cut -d ' ' -f-5)"
|
||||
|
||||
@@ -7,9 +7,7 @@ services:
|
||||
replicas: 0
|
||||
labels:
|
||||
- "swarm.cronjob.enable=true"
|
||||
# Note(3wc): every 5m, testing
|
||||
- "swarm.cronjob.schedule=*/5 * * * *"
|
||||
# Note(3wc): blank label to be picked up by `abra recipe sync`
|
||||
- "swarm.cronjob.schedule=${CRON_SCHEDULE}"
|
||||
restart_policy:
|
||||
condition: none
|
||||
entrypoint: [ "/usr/bin/backup.sh" ]
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
app:
|
||||
image: git.coopcloud.tech/coop-cloud/backup-bot-two:2.3.0-beta
|
||||
image: git.coopcloud.tech/coop-cloud/backup-bot-two:2.4.0
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
- "/var/lib/docker/volumes/:/var/lib/docker/volumes/"
|
||||
@@ -23,7 +23,7 @@ services:
|
||||
mode: 666
|
||||
deploy:
|
||||
labels:
|
||||
- coop-cloud.${STACK_NAME}.version=2.3.0+2.3.0-beta
|
||||
- coop-cloud.${STACK_NAME}.version=2.4.0+2.4.0
|
||||
- coop-cloud.${STACK_NAME}.timeout=${TIMEOUT}
|
||||
- coop-cloud.backupbot.enabled=true
|
||||
#entrypoint: ['tail', '-f','/dev/null']
|
||||
|
||||
+3
-2
@@ -4,7 +4,7 @@ set -e
|
||||
|
||||
CURL_OPTS="-s"
|
||||
# Check for basic auth
|
||||
if [ -n "$(cat /run/secrets/push_basicauth)" ]
|
||||
if [ -s /run/secrets/push_basicauth ]
|
||||
then
|
||||
CURL_OPTS="$CURL_OPTS -u $(cat /run/secrets/push_basicauth)"
|
||||
fi
|
||||
@@ -32,7 +32,8 @@ else
|
||||
fi
|
||||
|
||||
eval "$push_start_notification"
|
||||
if [ "$(backup --machine-logs create 2>&1 | tee /tmp/backup.log && (grep -q 'backup finished' /tmp/backup.log))" ]
|
||||
backup --machine-logs create 2>&1 | tee /tmp/backup.log
|
||||
if grep -q 'backup finished' /tmp/backup.log
|
||||
then
|
||||
eval "$push_success_notification"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user