Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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();"
share|improve this question
    
Maybe I'm saying bullshit, but maybe the cron job start another process while the previous is not finished. –  Anarko_Bizounours Jun 29 '11 at 15:16
2  
If you run the script manually, does it still spawn 3 rsync processes? –  sreimer Jun 29 '11 at 15:20
add comment

1 Answer

up vote 6 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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