-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaily.sh
More file actions
62 lines (55 loc) · 1.96 KB
/
daily.sh
File metadata and controls
62 lines (55 loc) · 1.96 KB
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
#!/usr/bin/env bash
#
# daily.sh
#
# Copyright (c) 2026 Pittsburgh Supercomputing Center (PSC),
# Brain Image Library (BIL)
#
# Author: icaoberg
#
# Description:
# This script runs the daily SpectraBrainz maintenance pipeline:
# 1. Executes the daily data processing script (daily.py)
# 2. Uploads results to Google Drive (upload_to_gdrive.py)
# 3. Backs up generated TSV files and the Excel report to the
# Brain Image Library backup location
#
# Usage:
# ./daily.sh
#
# Requirements:
# - Bash
# - Python available in PATH
# - daily.py and upload_to_gdrive.py in the same directory
# - rsync available
# - Write access to /bil/users/icaoberg/backups/spectranbrainz/
#
# Notes:
# - The pattern "2026*tsv" assumes TSV files are named with a 2026 prefix.
# - Adjust paths or filenames as needed for future years or deployments.
#
# Exit immediately if a command fails, a variable is undefined, or a pipeline fails
set -euo pipefail
# Run daily data processing
/bil/users/icaoberg/miniconda3/bin/python ./daily.py
# Upload results to Google Drive
/bil/users/icaoberg/miniconda3/bin/python ./upload_to_gdrive.py
# Backup all TSV files matching the 2026*tsv pattern (compressed)
for f in 2026*tsv; do
tar -czf "${f}.tar.gz" "$f"
done
rsync -ruv 2026*tsv.tar.gz /bil/users/icaoberg/backups/spectranbrainz/
rm -f 2026*tsv.tar.gz
# Backup the Excel report (compressed)
tar -czf spectrabrainz-report.xlsx.tar.gz spectrabrainz-report.xlsx
rsync -ruv spectrabrainz-report.xlsx.tar.gz /bil/users/icaoberg/backups/spectranbrainz/
rm -f spectrabrainz-report.xlsx.tar.gz
# On the last day of the month, copy the report with a YYYYMM-stamped filename and remove the original
today=$(date +%d)
last_day=$(date -d "$(date +%Y-%m-01) +1 month -1 day" +%d)
if [ "$today" -eq "$last_day" ]; then
stamp=$(date +%Y%m)
cp spectrabrainz-report.xlsx "spectrabrainz-report.${stamp}.xlsx"
rm spectrabrainz-report.xlsx
fi
echo "SpectraBrainz daily pipeline completed successfully."