-
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathremote-backup
More file actions
executable file
·26 lines (18 loc) · 910 Bytes
/
remote-backup
File metadata and controls
executable file
·26 lines (18 loc) · 910 Bytes
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
#!/bin/bash
set -o errexit -o nounset -o pipefail
timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
rm -rf remote-backup
mkdir remote-backup
mkdir remote-backup/$timestamp
sqlite3 attestation.db ".backup remote-backup/$timestamp/attestation.db"
sqlite3 samples.db ".backup remote-backup/$timestamp/samples.db"
tar -cC remote-backup $timestamp | zstd -9 --long | age -r $(cat backup-public-key.txt) -o remote-backup/$timestamp.tar.zst.age
expiry=$(date -ud '+60 day' +%s)
source cloud-archive.sh
swift upload --skip-container-put --segment-size 5368709122 -H "X-Delete-At: $expiry" \
--object-name $timestamp.tar.zst.age backup remote-backup/$timestamp.tar.zst.age
# work around https://bugs.launchpad.net/python-swiftclient/+bug/1478830
for segment in $(swift list backup_segments -p $timestamp.tar.zst.age/); do
swift post -H "X-Delete-At: $expiry" backup_segments "$segment"
done
rm -rf remote-backup