lots of updates, some t11 stuff
[distro-setup] / mail-backup-clean
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
17 shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
18 set -eE -o pipefail
19 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
20
21 cd /mnt/o/btrbk
22 tmp=(o*)
23 last_snap_date=${tmp[-1]#o.}
24 time=$(( $(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<$last_snap_date) +%s) -1 ))
25 # 1 second granularity, so we could have a duplicate file, oh well, not worrying about that.
26 find /bu/md -type f \! -newermt @$time -delete