ugnore dirs to avoid unnecessery logs

This commit is contained in:
Gani Georgiev
2026-08-22 19:18:20 +03:00
parent a293e1301d
commit 18cb3dc62f
+10 -2
View File
@@ -279,6 +279,13 @@ func createZip(be *BackupEvent, tempZipPath string) error {
excluded.Set(normalizePathExclude(auxDBFilename+"-wal"), struct{}{}) excluded.Set(normalizePathExclude(auxDBFilename+"-wal"), struct{}{})
excluded.Set(normalizePathExclude(auxDBFilename+"-shm"), struct{}{}) excluded.Set(normalizePathExclude(auxDBFilename+"-shm"), struct{}{})
// try to run manual checkpoints to ensure that all wal writes during the
// previous VACUUM INTO are transferred and don't accumulate
// (errors are ignore because some drivers may not support the wal_checkpoint pragma)
// ---------------------------------------------------------------
_, _ = be.App.NonconcurrentDB().NewQuery("PRAGMA wal_checkpoint(TRUNCATE)").Execute()
_, _ = be.App.AuxNonconcurrentDB().NewQuery("PRAGMA wal_checkpoint(TRUNCATE)").Execute()
// copy the rest of the pb_data // copy the rest of the pb_data
// --------------------------------------------------------------- // ---------------------------------------------------------------
err = copyDirToZip(zw, os.DirFS(be.App.DataDir()), excluded) err = copyDirToZip(zw, os.DirFS(be.App.DataDir()), excluded)
@@ -289,11 +296,12 @@ func createZip(be *BackupEvent, tempZipPath string) error {
return closeZip() return closeZip()
} }
// normalize the provided file path to always use and end with forward slash // normalize the provided file path to always end with forward slash
func normalizePathExclude(filePath string) string { func normalizePathExclude(filePath string) string {
return path.Clean(filePath) + "/" return path.Clean(filePath) + "/"
} }
// note: directories are ignored
func copyFileToZip(w *zip.Writer, localPath string, zipPath string) error { func copyFileToZip(w *zip.Writer, localPath string, zipPath string) error {
info, err := os.Stat(localPath) info, err := os.Stat(localPath)
if err != nil { if err != nil {
@@ -301,7 +309,7 @@ func copyFileToZip(w *zip.Writer, localPath string, zipPath string) error {
} }
if info.IsDir() { if info.IsDir() {
return fmt.Errorf("%s is a directory and not a regular file", localPath) return nil
} }
h, err := zip.FileInfoHeader(info) h, err := zip.FileInfoHeader(info)