diff --git a/doc/src/sgml/ref/pg_receivewal.sgml b/doc/src/sgml/ref/pg_receivewal.sgml
index 4d13c57ffa..5a880199d6 100644
--- a/doc/src/sgml/ref/pg_receivewal.sgml
+++ b/doc/src/sgml/ref/pg_receivewal.sgml
@@ -135,6 +135,28 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>-N</option></term>
+      <term><option>--no-sync</option></term>
+      <listitem>
+       <para>
+        By default, <command>pg_receivewal</command> flushes a WAL segment's
+        contents each time a feedback message is sent to the server depending
+        on the interval of time defined by
+        <literal>--status-interval</literal>.  This option causes
+        <command>pg_receivewal</command> to not issue such flushes waiting,
+        which is faster, but means that a subsequent operating system crash
+        can leave the WAL segments corrupt.  Generally, this option is useful
+        for testing but should not be used when doing WAL archiving on a
+        production deployment.
+       </para>
+
+       <para>
+        This option is incompatible with <literal>--synchronous</literal>.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-s <replaceable class="parameter">interval</replaceable></option></term>
       <term><option>--status-interval=<replaceable class="parameter">interval</replaceable></option></term>
diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c
index 888ae6c571..f3748ff509 100644
--- a/src/bin/pg_basebackup/pg_receivewal.c
+++ b/src/bin/pg_basebackup/pg_receivewal.c
@@ -40,6 +40,7 @@ static volatile bool time_to_stop = false;
 static bool do_create_slot = false;
 static bool slot_exists_ok = false;
 static bool do_drop_slot = false;
+static bool do_sync = true;
 static bool synchronous = false;
 static char *replication_slot = NULL;
 static XLogRecPtr endpos = InvalidXLogRecPtr;
@@ -81,6 +82,7 @@ usage(void)
 	printf(_("  -E, --endpos=LSN       exit after receiving the specified LSN\n"));
 	printf(_("      --if-not-exists    do not error if slot already exists when creating a slot\n"));
 	printf(_("  -n, --no-loop          do not loop on connection lost\n"));
+	printf(_("  -N, --no-sync          do not wait for changes to be written safely to disk\n"));
 	printf(_("  -s, --status-interval=SECS\n"
 			 "                         time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
 	printf(_("  -S, --slot=SLOTNAME    replication slot to use\n"));
@@ -425,7 +427,7 @@ StreamLog(void)
 	stream.stop_socket = PGINVALID_SOCKET;
 	stream.standby_message_timeout = standby_message_timeout;
 	stream.synchronous = synchronous;
-	stream.do_sync = true;
+	stream.do_sync = do_sync;
 	stream.mark_done = false;
 	stream.walmethod = CreateWalDirectoryMethod(basedir, compresslevel,
 												stream.do_sync);
@@ -476,6 +478,7 @@ main(int argc, char **argv)
 		{"port", required_argument, NULL, 'p'},
 		{"username", required_argument, NULL, 'U'},
 		{"no-loop", no_argument, NULL, 'n'},
+		{"no-sync", no_argument, NULL, 'N'},
 		{"no-password", no_argument, NULL, 'w'},
 		{"password", no_argument, NULL, 'W'},
 		{"status-interval", required_argument, NULL, 's'},
@@ -513,7 +516,7 @@ main(int argc, char **argv)
 		}
 	}
 
-	while ((c = getopt_long(argc, argv, "D:d:E:h:p:U:s:S:nwWvZ:",
+	while ((c = getopt_long(argc, argv, "D:d:E:h:p:U:s:S:nNwWvZ:",
 							long_options, &option_index)) != -1)
 	{
 		switch (c)
@@ -570,6 +573,9 @@ main(int argc, char **argv)
 			case 'n':
 				noloop = 1;
 				break;
+			case 'N':
+				do_sync = false;
+				break;
 			case 'v':
 				verbose++;
 				break;
@@ -637,6 +643,14 @@ main(int argc, char **argv)
 		exit(1);
 	}
 
+	if (synchronous && !do_sync)
+	{
+		fprintf(stderr, _("%s: cannot use --synchronous together with --no-sync\n"), progname);
+		fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
+				progname);
+		exit(1);
+	}
+
 	/*
 	 * Required arguments
 	 */
diff --git a/src/bin/pg_basebackup/t/020_pg_receivewal.pl b/src/bin/pg_basebackup/t/020_pg_receivewal.pl
index f9f7bf75ab..399d4364bb 100644
--- a/src/bin/pg_basebackup/t/020_pg_receivewal.pl
+++ b/src/bin/pg_basebackup/t/020_pg_receivewal.pl
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 use TestLib;
 use PostgresNode;
-use Test::More tests => 17;
+use Test::More tests => 18;
 
 program_help_ok('pg_receivewal');
 program_version_ok('pg_receivewal');
@@ -24,6 +24,9 @@ $primary->command_fails(
 $primary->command_fails(
 	[ 'pg_receivewal', '-D', $stream_dir, '--create-slot' ],
 	'failure if --create-slot specified without --slot');
+$primary->command_fails(
+	[ 'pg_receivewal', '-D', $stream_dir, '--synchronous', '--no-sync' ],
+	'failure if --synchronous specified without --no-sync');
 
 # Slot creation and drop
 my $slot_name = 'test';
