I have postgres 14 running on Windows 2019 server and I am using pg_basebackup to take regular backups.
The same powershell script which was working last week suddenly started giving me below errors.
No changes happened in the system except a host reboot.
For testing purposes, I tried giving full access to everyone to the both data directory/backup directory and still the same error.
PS G:FULL_Backup> Start-Process -FilePath "C:Program FilesPostgreSQL14binpg_basebackup.exe" -ArgumentList "-D G:FULL_BackupPG_Basebackup_2022-05-16_085816", "-Ft", "-z", "-R", "-U postgres", "-w" -Wait -NoNewWindow pg_basebackup: error: could not initiate base backup: ERROR: could not stat file or directory "./base/18119/43980": Permission denied pg_basebackup: removing contents of data directory "G:FULL_BackupPG_Basebackup_2022-05-16_085816"
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
The database server cannot read one of its own files, which should never happen. You have to fix that condition.
Probably causes for that are:
You are running a virus scanner on the data directory that locks the file. Don’t do that.
You changed ownership or permissions on that file. You should never modify anything in the data directory.