DEFINITIONS
Definitions More Info.
Definition ID
992
Title
POSTGRESQL
Category
NOTES
Definition
COPY Dynamicsql Maintenance Reindex Vacuum shell script
Definition Description
https://www.postgresql.org/message-id/FED2B709E3270E4B903EB0175A49BCB10475EF@dogbert.vale-housing.co.uk
#!/bin/bash
#This backup process starts by postgres system account cron job.
#Bu backup islemi postgres sistem kullanicisinin cron job tarafindan calistirilmaktadir
#EditDate: 20190527 12:50
#Edited By: Cuneyd Tanriverdi
#
[email protected]
#Asagidaki script database backuplarini almak icin yazilmistir
# Backup Start Date
Year=$(date +%Y)
Month=$(date +%m)
Day=$(date +%d)
current_time=$(date "+%Y%m%d%H%M%S")
backupPath=/storage/backup/$Year
echo "BLUECOLLAR ICIN REINDEX SCRIPT OLUSTURULUYOR"
psql -U postgres -d BlueCollar -c "COPY (SELECT format('REINDEX TABLE \"%s\".\"%s\";',schemaname,relname) FROM pg_stat_all_tables WHERE schemaname NOT IN('pg_catalog','pg_toast','information_schema') ORDER BY n_dead_tup DESC) TO '/storage/pgscripts/maintenance_scripts/Reindex_BlueCollar_$current_time.sql';"
sleep 5
echo "BLUECOLLAR REINDEX SCRIPT CALISTIRILIYOR"
psql -U postgres -d BlueCollar -f /storage/pgscripts/maintenance_scripts/Reindex_BlueCollar_$current_time.sql
echo "BLUECOLLAR ICIN VACUUM SCRIPT OLUSTURULUYOR"
psql -U postgres -d BlueCollar -c "COPY (SELECT format('VACUUM (VERBOSE, ANALYZE) \"%s\".\"%s\";', schemaname, relname) FROM pg_stat_all_tables ORDER BY n_dead_tup DESC) TO '/storage/pgscripts/maintenance_scripts/VacuumFor_BlueCollar_$current_time.sql';"
sleep 2
psql -U postgres -d BlueCollar -f /storage/pgscripts/maintenance_scripts/VacuumFor_BlueCollar_$current_time.sql
RecordBy
cunay
Record Date
29-11-2019 17:24:00
Düzenle
Kopyala
Sil