Support last update date #20
This commit is contained in:
+20
-13
@@ -1,9 +1,23 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 5,20,35,50 * * * * $HOME/userfiles/sql/hpr_db_backup.bash >> $HOME/userfiles/sql/cron.log 2>&1 &
|
||||
|
||||
# https://hackerpublicradio.org/hpr.sql.rss
|
||||
|
||||
# Runs periodically (comment suggests every 15 minutes).
|
||||
# Gets the latest information_schema.tables.UPDATE_TIME.
|
||||
# Compares it with last_update.txt.
|
||||
# If unchanged, does nothing.
|
||||
# If changed, waits at least 5 minutes since the previous dump.
|
||||
# Creates three mysqldump files:
|
||||
# full DB dump
|
||||
# site dump excluding reservations
|
||||
# another full recovery dump
|
||||
# Generates an RSS feed containing checksums of the site SQL.
|
||||
# Copies/rsyncs the site SQL and RSS to the HPR web host.
|
||||
# Records the detected DB timestamp in last_update.txt.
|
||||
|
||||
|
||||
#TODO
|
||||
#add a rss feed with the latest updates. Linking to the changes on gittea.
|
||||
# run that every 5 minutes and then if there is a change sleep 5 and confirm there has been no change since.
|
||||
@@ -24,18 +38,11 @@ hpr_database_file="hackerpublicradio.org/public_html/hpr.sql"
|
||||
|
||||
sync_delay_seconds="300" # 5 minutes
|
||||
|
||||
last_update_query="SELECT
|
||||
update_time
|
||||
FROM
|
||||
information_schema.tables tab
|
||||
WHERE
|
||||
update_time > (current_timestamp() - interval 30 day)
|
||||
AND table_type = 'BASE TABLE'
|
||||
AND table_name not in ('reservations')
|
||||
AND table_schema not in ('information_schema', 'sys', 'performance_schema', 'mysql')
|
||||
ORDER BY
|
||||
update_time DESC
|
||||
LIMIT 1;"
|
||||
last_update_query="USE hpr_hpr;
|
||||
SELECT GREATEST(
|
||||
(SELECT MAX(last_changed) FROM eps),
|
||||
(SELECT MAX(last_changed) FROM comments)
|
||||
) AS newest_last_changed;"
|
||||
|
||||
if [ ! -s "${credential_file}" ]
|
||||
then
|
||||
|
||||
Reference in New Issue
Block a user