Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1er6Dy-0007wp-7M for pgsql-admin@arkaria.postgresql.org; Wed, 28 Feb 2018 18:13:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1er6Dx-0006N7-9n for pgsql-admin@arkaria.postgresql.org; Wed, 28 Feb 2018 18:13:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1er6Dx-0006My-2d for pgsql-admin@lists.postgresql.org; Wed, 28 Feb 2018 18:13:05 +0000 Received: from mailout.easymail.ca ([64.68.200.34]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1er6Dt-0006f1-D3 for pgsql-admin@lists.postgresql.org; Wed, 28 Feb 2018 18:13:04 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 853B5C03A2; Wed, 28 Feb 2018 18:12:58 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo01-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ycawRUsYzivP; Wed, 28 Feb 2018 18:12:58 +0000 (UTC) Received: from shr-mbp-2.allegisgroup.com (unknown [216.152.106.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id AD049BFDD9; Wed, 28 Feb 2018 18:12:56 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: Reliable WAL file shipping over unreliable network From: scott ribe In-Reply-To: <954e01b6-b240-eb9a-5feb-8efd202fef5a@shopzeus.com> Date: Wed, 28 Feb 2018 11:12:03 -0700 Cc: pgsql-admin@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <9BE48599-5417-42BF-A7D3-554590878841@elevated-dev.com> References: <400AC9CD-1E43-422C-A689-70BDBAFF231E@elevated-dev.com> <954e01b6-b240-eb9a-5feb-8efd202fef5a@shopzeus.com> To: =?utf-8?Q?Nagy_L=C3=A1szl=C3=B3_Zsolt?= X-Mailer: Apple Mail (2.3445.5.20) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk There seem to be 2 fundamental misunderstandings here: 1) That other processes cannot see data written to a file until it is = flushed to disk; this is not true; while file data is still in file = cache, it is visible to other processes. 2) That rsync writes the file on the destination directly; it does not; = it writes into a temporary file and renames that file when it is = complete. > On Feb 28, 2018, at 10:53 AM, Nagy L=C3=A1szl=C3=B3 Zsolt = wrote: >=20 >=20 >>=20 >> Just use "-ac=E2=80=9D; you want -c option to ensure no data = corruption during the transfer. Do not delete the file; let Postgres = manage that. >>=20 >> Here is a snippet from I script I use for archiving. You also want = to make your script returns failure or success correctly. =20 >>=20 >> # SSH Command and options >> SSH_CMD=3D"ssh -o ServerAliveInterval=3D20 $ARCH_SERVER" >> STS=3D3 >>=20 >> OUTPUT=3D$(rsync -ac --rsync-path=3D"mkdir -p $ARCH_DIR && rsync" = $XLOGFILE $ARCH_SERVER:$ARCH_DIR/$WALFILE) >> if [ $? =3D=3D 0 ]; then=20 >> STS=3D0 >> fi >>=20 >> exit $STS >>=20 -- Scott Ribe https://www.linkedin.com/in/scottribe/ (303) 722-0567