pg_basebackup not running even after trying all the methods I configured pg_basebackup on another server, where it is running perfectly, but in one of the servers pg_basebackup is not running at all. Below are the error details. I tried multiple ways to troubleshoot, but didn't solve the issue; please help. The PostgreSQL version is 11.7.

-bash-4.2$ pg_basebackup -p 5432 -U postgres -Ft -D /var/lib/pgsql/backup/cluster1day1
pg_basebackup: could not get write-ahead log end position from server: ERROR:  could not open file "./.pg_ident.conf.swp": Permission denied
pg_basebackup: removing contents of data directory "/var/lib/pgsql/backup/cluster1day1"
You did something that you shouldn't do: you used the root user to edit a file in the PostgreSQL data directory using vi.

Then the session got interrupted, and now you are stuck with a swp file in the data directory that is owned by root. The operating system user postgres, who reads the files in the data directory to send them to pg_basebackup, cannot read that file and throws the appropriate error message.

Solution: remove the offending file from the data directory, and everything will work again.