@sudo-u postgres psql mentat_main -c"select count(*) as statistics_count, min(createtime) as from_date, max(createtime) as to_date from statistics_events;"
@sudo-u postgres psql mentat_main -c"select count(*) as changelog_count, min(createtime) as from_date, max(createtime) as to_date from changelogs_items;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as user_count, min(createtime) as from_date, max(createtime) as to_date from users;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as group_count, min(createtime) as from_date, max(createtime) as to_date from groups;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as filter_count, min(createtime) as from_date, max(createtime) as to_date from filters;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as network_count, min(createtime) as from_date, max(createtime) as to_date from networks;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as report_count, min(createtime) as from_date, max(createtime) as to_date from reports_events;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as statistics_count, min(createtime) as from_date, max(createtime) as to_date from statistics_events;"
@sudo-upostgrespsqlmentat_main-e-c"select count(*) as changelog_count, min(createtime) as from_date, max(createtime) as to_date from changelogs_items;"
for table_name in reports_events statistics_events changelogs_items
for table_name in reports_events statistics_events changelogs_items
do
do
print_subtitle "Dumping chunk of table ${table_name} from metadata database"
print_subtitle "Dumping chunk of table ${table_name} from metadata database"
sudo-u mentat psql mentat_main -c"copy (select * from ${table_name} where createtime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/${table_name}.dat
sudo-u mentat psql mentat_main -c"copy (select * from ${table_name} where createtime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/${table_name}.dat
print_subtitle "Dumping chunk of table events from event database"
print_subtitle "Dumping chunk of table events from event database"
sudo-u mentat psql mentat_events -c"copy (select * from events where storagetime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/events.dat
sudo-u mentat psql mentat_events -c"copy (select * from events where storagetime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/events.dat
sudo-u mentat gzip${BACKUP_DIR}/events.dat
print_subtitle "Dumping chunk of table events_json from event database"
print_subtitle "Dumping chunk of table events_json from event database"
sudo-u mentat psql mentat_events -c"copy (select events_json.* from events_json join events on events_json.id = events.id where events.storagetime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/events_json.dat
sudo-u mentat psql mentat_events -c"copy (select events_json.* from events_json join events on events_json.id = events.id where events.storagetime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/events_json.dat
sudo-u mentat gzip${BACKUP_DIR}/events_json.dat
print_subtitle "Dumping chunk of table events_thresholded from event database"
print_subtitle "Dumping chunk of table events_thresholded from event database"
sudo-u mentat psql mentat_events -c"copy (select * from events_thresholded join events on events_thresholded.eventid = events.id where events.storagetime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/events_thresholded.dat
sudo-u mentat psql mentat_events -c"copy (select * from events_thresholded join events on events_thresholded.eventid = events.id where events.storagetime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/events_thresholded.dat
print_subtitle "Dumping chunk of table thresholds from event database"
print_subtitle "Dumping chunk of table thresholds from event database"
sudo-u mentat psql mentat_events -c"copy (select * from thresholds where thresholdtime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/thresholds.dat
sudo-u mentat psql mentat_events -c"copy (select * from thresholds where thresholdtime >= '${BACKUP_DATE_FROM}'::timestamptz) to stdout">${BACKUP_DIR}/thresholds.dat