Script launching 3 copies of rsync
Posted
by
organicveggie
on Server Fault
See other posts from Server Fault
or by organicveggie
Published on 2011-06-29T15:13:10Z
Indexed on
2011/06/29
16:23 UTC
Read the original article
Hit count: 364
I have a simple script that uses rsync to copy a Postgres database to a backup location for use with Point In Time Recovery. The script is run every 2 hours via a cron job for the postgres user. For some strange reason, I can see three copies of rsync running in the process list. Any ideas why this might the case?
Here's the cron entry:
# crontab -u postgres -l
PATH=/bin:/usr/bin:/usr/local/bin
0 */2 * * * /var/lib/pgsql/9.0/pitr_backup.sh
And here's the ps list, which shows two copies of rsync running and one sleeping:
# ps ax |grep rsync
9102 ? R 2:06 rsync -avW /var/lib/pgsql/9.0/data/ /var/lib/pgsql/9.0/backups/pitr_archives/20110629100001/ --exclude pg_xlog --exclude recovery.conf --exclude recovery.done --exclude pg_log
9103 ? S 0:00 rsync -avW /var/lib/pgsql/9.0/data/ /var/lib/pgsql/9.0/backups/pitr_archives/20110629100001/ --exclude pg_xlog --exclude recovery.conf --exclude recovery.done --exclude pg_log
9104 ? R 2:51 rsync -avW /var/lib/pgsql/9.0/data/ /var/lib/pgsql/9.0/backups/pitr_archives/20110629100001/ --exclude pg_xlog --exclude recovery.conf --exclude recovery.done --exclude pg_log
And here's the uber simple script that seems to be the cause of the problem:
#!/bin/sh
LOG="/var/log/pgsql-pitr-backup.log"
base_backup_dir="/var/lib/pgsql/9.0/backups"
wal_archive_dir="$base_backup_dir/wal_archives"
pitr_archive_dir="$base_backup_dir/pitr_archives"
timestamp=`date +%Y%m%d%H%M%S`
backup_dir="$pitr_archive_dir/$timestamp"
mkdir -p $backup_dir
echo `date` >> $LOG
/usr/bin/psql -U postgres -c "SELECT pg_start_backup('$backup_dir');"
rsync -avW /var/lib/pgsql/9.0/data/ $backup_dir/ --exclude pg_xlog --exclude recovery.conf --exclude recovery.done --exclude pg_log
/usr/bin/psql -U postgres -c "SELECT pg_stop_backup();"
© Server Fault or respective owner