The question:
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"
Thanks,
Udhayan
The Solutions:
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.
Method 1
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0