diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index b11d9a6ba3..8c566889c0 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -3019,7 +3019,7 @@ psql "dbname=postgres replication=database" -c "IDENTIFY_SYSTEM;" Various temporary files and directories created during the operation of the PostgreSQL server, such as any file or directory beginning - with pgsql_tmp and temporary relations. + with pgsql_tmp, hidden files and temporary relations. diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index 79d3e657c3..a7c8ed7370 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -909,7 +909,7 @@ PostgreSQL documentation The backup will include all files in the data directory and tablespaces, including the configuration files and any additional files placed in the directory by third parties, except certain temporary files managed by - PostgreSQL. But only regular files and directories are copied, except that + PostgreSQL and hidden files. But only regular files and directories are copied, except that symbolic links used for tablespaces are preserved. Symbolic links pointing to certain directories known to PostgreSQL are copied as empty directories. Other symbolic links and special device files are skipped. diff --git a/doc/src/sgml/ref/pg_rewind.sgml b/doc/src/sgml/ref/pg_rewind.sgml index 9118f05bf2..005fa83b9e 100644 --- a/doc/src/sgml/ref/pg_rewind.sgml +++ b/doc/src/sgml/ref/pg_rewind.sgml @@ -381,8 +381,9 @@ GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, b backup_label, tablespace_map, pg_internal.init, - postmaster.opts, and - postmaster.pid, as well as any file or directory + postmaster.opts, + postmaster.pid, and + hidden files as well as any file or directory beginning with pgsql_tmp, are omitted. diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c index 5baea7535b..75b6af80cb 100644 --- a/src/backend/backup/basebackup.c +++ b/src/backend/backup/basebackup.c @@ -1202,6 +1202,10 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly, strlen(PG_TEMP_FILE_PREFIX)) == 0) continue; + /* Skip hidden files */ + if (de->d_name[0] == '.') + continue; + /* * Check if the postmaster has signaled us to exit, and abort with an * error in that case. The error handler further up will call diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 4d130a7f94..ea22d439ae 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -173,7 +173,7 @@ SKIP: # Write some files to test that they are not copied. foreach my $filename ( qw(backup_label tablespace_map postgresql.auto.conf.tmp - current_logfiles.tmp global/pg_internal.init.123)) + current_logfiles.tmp global/pg_internal.init.123 .donotcopy)) { open my $file, '>>', "$pgdata/$filename"; print $file "DONOTCOPY"; @@ -244,7 +244,7 @@ foreach my $dirname ( # These files should not be copied. foreach my $filename ( qw(postgresql.auto.conf.tmp postmaster.opts postmaster.pid tablespace_map current_logfiles.tmp - global/pg_internal.init global/pg_internal.init.123)) + global/pg_internal.init global/pg_internal.init.123 .donotcopy)) { ok(!-f "$tempdir/backup/$filename", "$filename not copied"); } diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 19eb67e485..d3c16acf0d 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -337,6 +337,10 @@ scan_directory(const char *basedir, const char *subdir, bool sizeonly) strlen(PG_TEMP_FILES_DIR)) == 0) continue; + /* Skip hidden files */ + if (de->d_name[0] == '.') + continue; + snprintf(fn, sizeof(fn), "%s/%s", path, de->d_name); if (lstat(fn, &st) < 0) pg_fatal("could not stat file \"%s\": %m", fn); diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index 2316f611b2..ff975e5601 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -114,6 +114,9 @@ append_to_file "$pgdata/global/pgsql_tmp/1.1", "foo"; append_to_file "$pgdata/global/pg_internal.init", "foo"; append_to_file "$pgdata/global/pg_internal.init.123", "foo"; +# These are non-postgres files, which should be ignored by the scan +append_to_file "$pgdata/global/.donotscan", "foo"; + # Enable checksums. command_ok([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ], "checksums successfully enabled in cluster"); diff --git a/src/bin/pg_rewind/file_ops.c b/src/bin/pg_rewind/file_ops.c index 25996b4da4..77ff8ac5d2 100644 --- a/src/bin/pg_rewind/file_ops.c +++ b/src/bin/pg_rewind/file_ops.c @@ -398,6 +398,10 @@ recurse_dir(const char *datadir, const char *parentpath, strcmp(xlde->d_name, "..") == 0) continue; + /* Skip hidden files */ + if (xlde->d_name[0] == '.') + continue; + snprintf(fullpath, sizeof(fullpath), "%s/%s", fullparentpath, xlde->d_name); if (lstat(fullpath, &fst) < 0) diff --git a/src/bin/pg_rewind/t/003_extrafiles.pl b/src/bin/pg_rewind/t/003_extrafiles.pl index fd2bee5d20..95ae15f946 100644 --- a/src/bin/pg_rewind/t/003_extrafiles.pl +++ b/src/bin/pg_rewind/t/003_extrafiles.pl @@ -35,6 +35,9 @@ sub run_test append_to_file "$test_primary_datadir/tst_both_dir/both_subdir/both_file3", "in both3"; + append_to_file + "$test_primary_datadir/tst_both_dir/.donotcopy", + "in both4"; RewindTest::create_standby($test_mode); @@ -82,6 +85,7 @@ sub run_test \@paths, [ "$test_primary_datadir/tst_both_dir", + "$test_primary_datadir/tst_both_dir/.donotcopy", "$test_primary_datadir/tst_both_dir/both_file1", "$test_primary_datadir/tst_both_dir/both_file2", "$test_primary_datadir/tst_both_dir/both_subdir",