-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·59 lines (44 loc) · 1.6 KB
/
Copy pathbackup.sh
File metadata and controls
executable file
·59 lines (44 loc) · 1.6 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
#!/usr/bin/env bash
set -eou pipefail
shopt -s nullglob
YEAR=$(date +"%Y")
MONTH=$(date +"%m")
DAY=$(date +"%d")
cd /opt/islandora/backups
mkdir -p "$YEAR/$MONTH/$DAY"
cd "$YEAR/$MONTH/$DAY"
docker exec lehigh-d10-drupal-1 \
drush sql-dump -y --skip-tables-list=cache,cache_*,watchdog \
--structure-tables-list=cache,cache_*,watchdog \
--debug > drupal.sql
gzip drupal.sql
docker exec lehigh-d10-fcrepo-1 \
mysqldump -h mariadb -u fcrepo \
-p"$(cat /opt/islandora/d10_lehigh_agile/secrets/FCREPO_DB_PASSWORD)" \
fcrepo > fcrepo.sql
gzip fcrepo.sql
# remove all backups older than one week
# except ones ran on the first of the month so we have some history
find /opt/islandora/backups -type f -mtime +14 | grep -Ev "\/01\/[a-z\.]" | xargs rm || echo "No files older than 14d"
# remove empty directories
find /opt/islandora/backups -type d -empty -exec rm -rf {} \; || echo "No non empty directories"
# we're running backups nightly
# so lets go ahead and keep the filesystem trim from old images
docker system prune -af
docker exec lehigh-d10-drupal-1 drush cr || echo "continuing"
# cleanup old temp files
find "/opt/islandora/volumes/tmp" -type f -mtime +1 -exec rm -f {} \;
# clear out all bad cached manifests
for JSON in /opt/islandora/volumes/drupal-private-files/iiif/preserve.lehigh.edu/*/node/*/book-manifest.json; do
if [ ! -f "$JSON" ]; then
continue
fi
CLEANUP=0
jq . "$JSON" > /dev/null || CLEANUP=1
if [ "$CLEANUP" -eq 0 ]; then
continue
fi
echo "Cleaning up $JSON"
rm "$JSON" || echo "File doesn't exist"
done
docker exec lehigh-d10-drupal-1 scripts/cron.daily/run.sh