Re: Use of rsync for data directory copying

From: David Kerr <dmk(at)mr-paradox(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Use of rsync for data directory copying
Date: 2012-07-10 03:00:48
Message-ID: 053273EA-AB8F-4B3F-9571-99A70FC587C5@mr-paradox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Jul 9, 2012, at 7:48 PM, Bruce Momjian wrote:

> Rsync is popular with Postgres users, but I don't understand how they
> are using the default check mode (file size, modification time) to
> synchronize shut-down data directories? It seems they would have to use
> --checksum because it is too easy for files to change in the same
> second, and for a backend to write into the middle of a file.
>
> Is everyone who is using rsync with Postgres also using --checksum mode?

I must be missing something, if they're shut down you can't write to them. =)

I do use rsync though for resyncing my mirror's, it's been working great so far. I assume
that the WAL fixes anything that gets goofed up in the copy. (hopefully I've been assuming correctly.)

---
#!/bin/ksh

SOURCE=masterdbserver

. /etc/sysconfig/pgsql/postgresql-9.1

export PGDATA
export PGPORT

rm -f $PGDATA/failover

pg_ctl stop -D $PGDATA -m immediate
psql -h $SOURCE -p $PGPORT <<EOD
checkpoint;
select pg_start_backup('mirror');
EOD
rsync -avv --delete-delay \
--exclude postgresql.conf \
--exclude pg_hba.conf \
--exclude server.conf \
--exclude archive.conf \
--exclude recovery.conf \
--exclude recovery.done \
--exclude pg_ident.conf \
--exclude failover \
--exclude pg_xlog \
--exclude postmaster.pid \
$SOURCE:$PGDATA/ $PGDATA
psql -h $SOURCE -p $PGPORT -c "select pg_stop_backup()"
cp $PGDATA/recovery.done $PGDATA/recovery.conf
pg_ctl start -D $PGDATA

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Farina 2012-07-10 06:11:39 Re: Synchronous Standalone Master Redoux
Previous Message Bruce Momjian 2012-07-10 02:48:06 Use of rsync for data directory copying