- 归档信息文件 .backup
- archive_status文件夹
- Postgresql arch process 进程解析
归档文件
000000010000000000000002.000000D0.backup
do_pg_stop_backup()
产生backup 信息文件
1 |
|
Start WAL Location: offset;
archive_status作用
用于标记文件拷贝情况.
postgres: archiver process
postmaster.c:PostmasterMain()
1 | pqsignal_no_restart(SIGCHLD, reaper); |
postmaster.c:reaper()
1 | /* |
pgarch.c:pgarch_ArchiverCopyLoop()
使用.ready的archive_status循环遍历所有xlog并归档它们… 大多数情况下我们希望这是一个单独文件, 后端会将这些文件添加到需要归档的列表中. 而我们仍在复制早期的归档文件.
pgarch.c:pgarch_archiveXlog()
Invokes system(3) to copy one archive file to wherever it should go
Returns true if successful
1 | rc = system(xlogarchcmd); |
利用postgresql.conf中archive_command的参数. 进行系统拷贝;
pgarch.c:pgarch_archiveDone()
Emit notification that an xlog file has been successfully archived. We do this by renaming the status file from XXXX.ready to XXXX.done. Eventually, a checkpoint process will notice this and delete both the XXXX.done file and the xlog file itself. – 检查点进程将会清理xxx.done 和 xlog本身文件.
实现:
1 | static void |
xlogarchve.c
- XLogArchiveNotify
- Create an archive notification file
- XLogArchiveNotifySeg
- Convenience routine to notify using segment number representation of filename
- XLogArchiveForceDone
- Emit notification forcibly that an XLOG segment file has been successfully archived, bu creating \
.done regardless of whether \ .ready exists or not.
- Emit notification forcibly that an XLOG segment file has been successfully archived, bu creating \
- XLogArchiveCheckDone
- XLogArchiveIsBusy
- Check to see if an XLOG segment file is still unarchived
- XLogArchiveIsReadyOrDone
- XLogArchiveIsReady
- Check to see if an XLOG segment file has an archive notification (.ready) file.
- XLogArchiveCleanup
- Cleanup archive notification file(s) for a particular xlog segment