-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrestic.rb
36 lines (26 loc) · 1.04 KB
/
restic.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
require 'securerandom'
class Restic < Formula
desc "restic backup program"
homepage "https://restic.github.io/"
url "https://github.com/restic/restic/archive/v0.1.0.tar.gz"
sha256 "df7842cb690a56ce5371013a958d9f324072429897511d4bbfc092d76303f198"
version "0.1.0"
head "https://github.com/restic/restic.git"
depends_on 'go'
def install
system "make"
system "mkdir #{prefix}/bin"
system "cp restic #{prefix}/bin"
end
test do
test_repo_name = SecureRandom.hex
test_repo_path = "/tmp/restic-#{test_repo_name}"
system "RESTIC_PASSWORD=foo restic -r #{test_repo_path} init"
system "RESTIC_PASSWORD=foo restic -r #{test_repo_path} backup #{$0}"
snapshot = `RESTIC_PASSWORD=foo restic -r #{test_repo_path} snapshots | tail -n+3 | head -n1 | awk '{print $1}'`
snapshot.chomp!
system "RESTIC_PASSWORD=foo restic -r #{test_repo_path} restore #{snapshot} -t #{test_repo_path}-restore"
system "diff -q #{$0} #{test_repo_path}-restore/#{File.basename($0)}"
system "rm -rf #{test_repo_path}"
end
end