Skip to content

Commit 00ab266

Browse files
New docker image (#161)
* add openssh to docker image * docs: add contrib * add ca-certificates to docker image
1 parent e770b2d commit 00ab266

File tree

10 files changed

+99
-6
lines changed

10 files changed

+99
-6
lines changed

build/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ FROM alpine:latest
33
LABEL maintainer Fred <fred@gcreativeprojects.tech>
44

55
ARG ARCH=amd64
6+
ENV TZ=Etc/UTC
67

78
COPY build/restic-${ARCH} /usr/bin/restic
89
COPY build/rclone-${ARCH} /usr/bin/rclone
910
COPY resticprofile /usr/bin/resticprofile
1011

12+
RUN apk add --no-cache openssh-client-default curl tzdata ca-certificates
13+
1114
VOLUME /resticprofile
1215
WORKDIR /resticprofile
1316

commands.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
"io"
1010
"os"
1111
"regexp"
12-
"runtime"
1312
"sort"
1413
"strconv"
1514
"strings"
1615

1716
"github.com/creativeprojects/clog"
1817
"github.com/creativeprojects/resticprofile/config"
1918
"github.com/creativeprojects/resticprofile/constants"
19+
"github.com/creativeprojects/resticprofile/platform"
2020
"github.com/creativeprojects/resticprofile/remote"
2121
"github.com/creativeprojects/resticprofile/schedule"
2222
"github.com/creativeprojects/resticprofile/term"
@@ -570,7 +570,7 @@ func retryElevated(err error, flags commandLineFlags) error {
570570
return nil
571571
}
572572
// maybe can find a better way than searching for the word "denied"?
573-
if runtime.GOOS == "windows" && !flags.isChild && strings.Contains(err.Error(), "denied") {
573+
if platform.IsWindows() && !flags.isChild && strings.Contains(err.Error(), "denied") {
574574
clog.Info("restarting resticprofile in elevated mode...")
575575
err := elevated(flags)
576576
if err != nil {
@@ -582,7 +582,7 @@ func retryElevated(err error, flags commandLineFlags) error {
582582
}
583583

584584
func elevated(flags commandLineFlags) error {
585-
if runtime.GOOS != "windows" {
585+
if !platform.IsWindows() {
586586
return errors.New("only available on Windows platform")
587587
}
588588

contrib/schedule-in-docker/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Scheduling inside a docker container
2+
3+
[Discussion](https://github.com/creativeprojects/resticprofile/issues/74)
4+
5+
You can schedule your backups with resticprofile by running `crond` inside a container.
6+
7+
Here's a `docker-compose` example:
8+
9+
```yaml
10+
version: '2'
11+
12+
services:
13+
scheduled-backup:
14+
image: creativeprojects/resticprofile:${RP_VERSION:-latest}
15+
container_name: backup_container
16+
hostname: backup_container
17+
entrypoint: '/bin/sh'
18+
command:
19+
- '-c'
20+
- 'resticprofile schedule --all && crond -f'
21+
volumes:
22+
- ~/.ssh:/root/.ssh
23+
- './profiles.yaml:/etc/resticprofile/profiles.yaml:ro'
24+
- './key:/etc/resticprofile/key:ro'
25+
environment:
26+
- TZ=Etc/UTC
27+
```
28+
29+
with the corresponding resticprofile configuration running a backup every 15 minutes:
30+
31+
```yaml
32+
33+
global:
34+
scheduler: crond
35+
36+
default:
37+
password-file: key
38+
repository: sftp:storage_server:/tmp/backup
39+
initialize: true
40+
backup:
41+
source: /
42+
exclude-caches: true
43+
one-file-system: true
44+
schedule: "*:00,15,30,45"
45+
schedule-permission: system
46+
check-before: true
47+
48+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '2'
2+
3+
services:
4+
scheduled-backup:
5+
image: creativeprojects/resticprofile:${RP_VERSION:-latest}
6+
container_name: backup_container
7+
hostname: backup_container
8+
entrypoint: '/bin/sh'
9+
command:
10+
- '-c'
11+
- 'resticprofile schedule --all && crond -f'
12+
volumes:
13+
- ~/.ssh:/root/.ssh
14+
- './profiles.yaml:/etc/resticprofile/profiles.yaml:ro'
15+
- './key:/etc/resticprofile/key:ro'
16+
environment:
17+
- TZ=Etc/UTC

contrib/schedule-in-docker/key

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a test backup key
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
global:
3+
scheduler: crond
4+
5+
default:
6+
password-file: key
7+
repository: sftp:nas17:/tmp/backup
8+
initialize: true
9+
backup:
10+
source: /
11+
exclude-caches: true
12+
one-file-system: true
13+
schedule: "*:00,05,10,15,30,45"
14+
schedule-permission: system
15+
check-before: true

docs/content/contributions/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ I have created a [contributions section](https://github.com/creativeprojects/res
1515
- [shell completion](https://github.com/creativeprojects/resticprofile/tree/master/contrib/completion)
1616
- [export status to grafana](https://github.com/creativeprojects/resticprofile/tree/master/contrib/grafana)
1717
- [send email on systemd timer error](https://github.com/creativeprojects/resticprofile/tree/master/contrib/systemd)
18-
- [get backup status information in zabbix](https://github.com/creativeprojects/resticprofile/tree/master/contrib/zabbix)
18+
- [get backup status information in zabbix](https://github.com/creativeprojects/resticprofile/tree/master/contrib/zabbix)
19+
- [scheduling inside a docker container](https://github.com/creativeprojects/resticprofile/tree/master/contrib/schedule-in-docker)

docs/content/installation/docker/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@ Starting from version `0.18.0`, the resticprofile docker image is available in t
4545

4646
Starting from version `0.18.0`, the resticprofile docker image also includes [rclone][1].
4747

48+
## Scheduling with docker compose
49+
50+
There's an example in the contribution section how to schedule backups in a long running container.
51+
The configuration needs to specify the use `crond` as a scheduler.
52+
53+
See [contrib][2]
54+
4855
[1]: https://rclone.org/
56+
[2]: https://github.com/creativeprojects/resticprofile/tree/master/contrib/schedule-in-docker

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// These fields are populated by the goreleaser build
2929
var (
30-
version = "0.19.0-dev"
30+
version = "0.20.0-dev"
3131
commit = ""
3232
date = ""
3333
builtBy = ""

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sonar.organization=creativeprojects
22
sonar.projectKey=creativeprojects_resticprofile
33
sonar.projectName=resticprofile
4-
sonar.projectVersion=0.18.0
4+
sonar.projectVersion=0.20.0
55

66
sonar.sources=.
77
sonar.exclusions=**/*_test.go,/docs/**

0 commit comments

Comments
 (0)