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
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:




timestamp=`date +%Y%m%d%H%M%S`

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();"
  • 2
    If you run the script manually, does it still spawn 3 rsync processes? – sreimer Jun 29 '11 at 15:20

It's normal for rsync to fork multiple processes, it looks like that's what's going on here, it's nothing to be concerned with. The fact that the process IDs are sequential in the ps output would very strongly indicate that they're not jobs that are still running two hours later when the next job starts.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.