File: retire-volume

package info (click to toggle)
rsbackup 10.0-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,908 kB
  • sloc: cpp: 10,859; sh: 2,566; makefile: 387; perl: 11
file content (99 lines) | stat: -rwxr-xr-x 5,080 bytes parent folder | download | duplicates (4)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
# Copyright © 2011, 2012, 2014-15, 2017 Richard Kettlewell.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
set -e
. ${srcdir:-.}/setup.sh

setup

echo "| Create backup"
RSBACKUP_TIME=315532800 s ${RSBACKUP} --backup --text ${WORKSPACE}/got/create.txt --html ${WORKSPACE}/got/create.html
# volume1: 1980-01-01
# volume2: 1980-01-01
sqlite3 ${WORKSPACE}/logs/backups.db "SELECT host,volume,device,id,rc,status FROM backup" > ${WORKSPACE}/got/created-db.txt
compare ${srcdir:-.}/expect/retire-volume/created-db.txt ${WORKSPACE}/got/created-db.txt
exists ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
exists ${WORKSPACE}/store1/host1/volume2/1980-01-01T00:00:00
exists ${WORKSPACE}/store2/host1/volume1/1980-01-01T00:00:00
exists ${WORKSPACE}/store2/host1/volume1/1980-01-01T00:00:00
compare ${srcdir:-.}/expect/retire-volume/create.txt ${WORKSPACE}/got/create.txt
compare ${srcdir:-.}/expect/retire-volume/create.html ${WORKSPACE}/got/create.html

echo "| Edit config"
sed < ${WORKSPACE}/config > ${WORKSPACE}/config.new 's/^ *volume volume2.*//;s/^ *min-backups 2//'
mv ${WORKSPACE}/config.new ${WORKSPACE}/config

echo "| --dry-run should do nothing"
RSBACKUP_TIME=315532800 RUN=dryrun s ${RSBACKUP} --retire --dry-run --text ${WORKSPACE}/got/dryrun.txt --html ${WORKSPACE}/got/dryrun.html host1:volume2
sqlite3 ${WORKSPACE}/logs/backups.db "SELECT host,volume,device,id,rc,status FROM backup" > ${WORKSPACE}/got/created-db-bis.txt
compare ${srcdir:-.}/expect/retire-volume/created-db.txt ${WORKSPACE}/got/created-db-bis.txt
exists ${WORKSPACE}/dryrun-dev-pre.ran
exists ${WORKSPACE}/dryrun-dev-post.ran
absent ${WORKSPACE}/dryrun-dev-pre.acted
absent ${WORKSPACE}/dryrun-dev-post.acted
exists ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
exists ${WORKSPACE}/store1/host1/volume2/1980-01-01T00:00:00
exists ${WORKSPACE}/store2/host1/volume1/1980-01-01T00:00:00
exists ${WORKSPACE}/store2/host1/volume1/1980-01-01T00:00:00
compare ${srcdir:-.}/expect/retire-volume/dryrun.txt ${WORKSPACE}/got/dryrun.txt
compare ${srcdir:-.}/expect/retire-volume/dryrun.html ${WORKSPACE}/got/dryrun.html

echo "| retire volume2"
RSBACKUP_TIME=315532800 RUN=retire s ${RSBACKUP} --verbose --retire --force --text ${WORKSPACE}/got/volume2.txt --html ${WORKSPACE}/got/volume2.html host1:volume2
sqlite3 ${WORKSPACE}/logs/backups.db "SELECT host,volume,device,id,rc,status FROM backup" > ${WORKSPACE}/got/volume2-db.txt
compare ${srcdir:-.}/expect/retire-volume/volume2-db.txt ${WORKSPACE}/got/volume2-db.txt
exists ${WORKSPACE}/retire-dev-pre.ran
exists ${WORKSPACE}/retire-dev-post.ran
exists ${WORKSPACE}/retire-dev-pre.acted
exists ${WORKSPACE}/retire-dev-post.acted
exists ${WORKSPACE}/store1/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store1/host1/volume2
exists ${WORKSPACE}/store2/host1/volume1/1980-01-01T00:00:00
absent ${WORKSPACE}/store2/host1/volume2
compare ${srcdir:-.}/expect/retire-volume/volume2.txt ${WORKSPACE}/got/volume2.txt
compare ${srcdir:-.}/expect/retire-volume/volume2.html ${WORKSPACE}/got/volume2.html

echo "| No negative selections for retire"
if RSBACKUP_TIME=315532800 RUN=retire s ${RSBACKUP} --verbose --retire --force host1 -host1:volume3 2>${WORKSPACE}/errors; then
  echo "Unexpected success"
  exit 1
fi

echo "| Cannot retire all hosts"
if RSBACKUP_TIME=315532800 RUN=retire s ${RSBACKUP} --verbose --retire --force '*' 2>${WORKSPACE}/errors; then
  echo "Unexpected success"
  exit 1
fi

echo "| Edit config"
sed < ${WORKSPACE}/config > ${WORKSPACE}/config.new 's/^ *volume volume2.*//;s/^ *min-backups 2//'
mv ${WORKSPACE}/config.new ${WORKSPACE}/config

echo "| Retire all volumes"
RSBACKUP_TIME=315532800 RUN=retire s ${RSBACKUP} --verbose --retire --force --text ${WORKSPACE}/got/all.txt --html ${WORKSPACE}/got/all.html host1
sqlite3 ${WORKSPACE}/logs/backups.db "SELECT host,volume,device,id,rc,status,log FROM backup" > ${WORKSPACE}/got/all-db.txt
compare ${srcdir:-.}/expect/retire-volume/retire-volume-3.txt ${WORKSPACE}/got/all-db.txt
exists ${WORKSPACE}/retire-dev-pre.ran
exists ${WORKSPACE}/retire-dev-post.ran
exists ${WORKSPACE}/retire-dev-pre.acted
exists ${WORKSPACE}/retire-dev-post.acted
absent ${WORKSPACE}/store1/host1/volume1
absent ${WORKSPACE}/store1/host1/volume2
absent ${WORKSPACE}/store2/host1/volume1
absent ${WORKSPACE}/store2/host1/volume2
compare ${srcdir:-.}/expect/retire-volume/all.txt ${WORKSPACE}/got/all.txt
compare ${srcdir:-.}/expect/retire-volume/all.html ${WORKSPACE}/got/all.html

cleanup