0 like 0 dislike

Please log in or register to answer this question.

1 Answer

0 like 0 dislike
answered by (4k points)  
edited by

PostgreSQL Logs Moving & Deleting :

Older than 10 days postgres logfiles Compressing :

find /data/pg_log/ -mtime +10 | xargs  tar -czvPf /nijam/older_log.tar.gz

Older than 12 days postgres logfiles removing :

find /data/pg_log/ -type f -name "*.log" -mtime +11 -exec rm {} \;

But before that get a listing to see what you are about to delete and tar

find /data/pg_log/ -type f -name "*.log" -mtime +10 -exec ls -tr {} \;

PostgreSQL Archives Moving Script with TAR :

This script will move the postgres archive to some other location with tar.zip format while compressing the archive source files will deleted automatically.

/opt/PostgreSQL/9.3/bin/psql -U username -d dbname -p 5432 -c "select pg_switch_xlog();"
tar --remove-files -cvzf /archive_backup/archive_log_on_`date +%d-%m-%y-%T`.tar.gz /archive/archive_logs/*


Related questions

0 like 0 dislike
1 answer
asked Mar 31, 2019 in MySQL Database Forum by nijamutheen j (13.4k points)  
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer