-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrestic-automatic-backup-scheduler.rb
64 lines (54 loc) · 2.43 KB
/
restic-automatic-backup-scheduler.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class ResticAutomaticBackupScheduler < Formula
desc "Automatic restic backup schedule using Backblaze B2 storage & macOS LaunchAgents"
homepage "https://github.com/erikw/restic-automatic-backup-scheduler"
url "https://github.com/erikw/restic-automatic-backup-scheduler/archive/refs/tags/v7.4.0.tar.gz"
sha256 "0adf4a5aaa25bf9860b22fb67972f6b892caa9a06d2c5acd59195725f5b4e6dc"
license "BSD-3-Clause"
bottle do
root_url "https://github.com/erikw/homebrew-tap/releases/download/restic-automatic-backup-scheduler-7.4.0"
sha256 cellar: :any_skip_relocation, x86_64_linux: "beebe3d03806f04c5c94462491fa43b0219aa4f522e5ab7446871ad89727a96a"
end
depends_on "bash"
depends_on "erikw/tap/restic-automatic-backup-scheduler-check"
depends_on "restic"
# Variables documented at:
# https://docs.brew.sh/Formula-Cookbook#variables-for-directory-locations
def install
args = %W[
PREFIX=#{prefix}
INSTALL_PREFIX=#{HOMEBREW_PREFIX}
SYSCONFDIR=#{etc}/..
LAUNCHAGENTDIR=#{prefix}
]
system "make", "install-launchagent", *args
# The LaunchAgent need to have a special name for brew-services to pick it up.
# Reference: https://docs.brew.sh/Formula-Cookbook#launchd-plist-files
prefix.install_symlink \
"Library/LaunchAgents/com.github.erikw.restic-backup.plist" => "#{plist_name}.plist"
end
def caveats
<<~EOS
===========
To get started with backups, do the following:
1. Edit config files at /etc/restic/*.env.sh
1. Enable the backup service:
$ brew services start restic-automatic-backup-scheduler
2. If you want a different schedule or profile, edit + restart:
$ vim ~/Library/LaunchAgents/homebrew.mxcl.restic-automatic-backup-scheduler.plist
$ brew services restart restic-automatic-backup-scheduler
4. To stop the backups,
$ brew services stop restic-automatic-backup-scheduler
4. (recommended) enable the check service:
$ brew services start restic-automatic-backup-scheduler-check
**NOTE** If you updated the .plist file, you need to restart the service to
reload the values.
See full tutorial at https://github.com/erikw/restic-automatic-backup-scheduler
===========
EOS
end
test do
act = shell_output("#{bin}/resticw -h").lines.first.strip
exp = "A little wrapper over restic just to handle profiles and environment loading."
assert_equal exp, act
end
end