-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpurge.sh
executable file
·55 lines (47 loc) · 968 Bytes
/
purge.sh
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
#!/bin/bash
cd `dirname $0`
. ./common.sh
DRY_RUN=--dry-run
COMPACT=''
if [ "$1" = '--really' ]
then
DRY_RUN=''
COMPACT=--compact
fi
forget() {
use_archive_repository
echo forget non-transient files
restic forget $DRY_RUN $COMPACT \
--tag mysql \
--tag postgresql \
--tag files \
--keep-tag transient \
--keep-daily 14 \
--keep-weekly 5 \
--keep-monthly 4
use_transient_repository
if [ -n "$RESTIC_REPOSITORY" ]
then
echo forget transient files
# Don't group transient files by path as the paths may change from one
# snapshot to the next (e.g. paths with dates in them).
restic forget $DRY_RUN $COMPACT \
--group-by host \
--tag transient \
--keep-daily 2
fi
}
prune() {
use_archive_repository
restic prune
use_transient_repository
test -n "$RESTIC_REPOSITORY" && restic prune
}
if [ "$1" = '--really' ]
then
forget >$LOG
egrep '^(forget|Applying|(keep|remove) [[:digit:]]+ snapshot)' $LOG
prune
else
forget
fi