简体   繁体   中英

When can I delete old pg_wal files and old archive files from postgres database, i have two different directory for both of them

i have postgres 12 database with master slave configuration. the space of backup is near by 70%, i want to create some space for smooth functioning of DB. i can moved backup of db in different location, but it is not sufficient. there is lots of space taken by pg_wal files and archive files. i have wo different directories for both of them. can i delete some of them? last pg_wal file is 0000000100000004000000D9 on date of 07-10-2021 and latest on is 0000000100000007000000D8 on date of 10-02-2022. same as last archive file is 0000000100000004000000DE on date of 01-05-2021 and latest is 0000000100000007000000D7 on date of 10-02-2022. can i delete some of them like til previous month.

Files in pg_wal are deleted by the system, you should figure out why it is not doing so (for 4 months!)

Files in the archive can be deleted when they are no longer needed. That is a matter of your policy. Do you still need them for PITR? I don't know, you need to tell us. Does the replica still need them to get caught up? I assume it is not that far behind, or you would have said something to start with. Maybe you have two replicas and one got forgotten about. Maybe you don't care about PITR and are only interested in streaming for the replica, and your archive isn't needed at all and was set up by mistake.

By the way, WAL files usually compress very well. xz will often shrink them by >90%. So if you need more time to think about what your policy is, you can compress the archived files to free up some space while you do so. Don't compress the ones in pg_wal though, just the archive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM