Обсуждение: Cron job doing VACUUM and BACUP from root
Have been searching around the last two days to find some scripts or cron jobs to automate backup and vacuum. I'm running a small db on PSQL 7.02 / RH 7 and keeping my login as root. I know how to set up cron from root and I believe it should be possible to call the job from root, or am I totally wrong. For what I have been doing I only get FATAL 1 errors, believe that's from not being in su postgres ? Any help and assistance (step by step) to a novice would be helpful. Regards, Aage J. Skjolingstad
> -----Original Message----- > From: Aage J. Skjolingstad [mailto:aages@aajs.com] > Sent: 04 November 2000 19:30 > To: pgsql-interfaces@postgresql.org > Subject: [INTERFACES] Cron job doing VACUUM and BACUP from root > > > Have been searching around the last two days to find some scripts or > cron jobs to automate backup and vacuum. > > I'm running a small db on PSQL 7.02 / RH 7 and keeping my login as > root. > I run the following (extremely basic) script on RH6 with PostgreSQL 7.0.1: HTH, Regards Dave. ----------> #! /bin/sh cd / rm /var/log/backup.old mv /var/log/backup.log /var/log/backup.old echo Subject: backup results >> /var/log/backup.log echo >> /var/log/backup.log echo Mephesto Auto-Backup started: `date` >> /var/log/backup.log echo >> /var/log/backup.log echo Vacuuming Database... >> /var/log/backup.log su - postgres -c "/usr/local/pgsql/bin/psql alarm -c vacuum;" su - postgres -c "/usr/local/pgsql/bin/psql helpdesk -c vacuum;" su - postgres -c "/usr/local/pgsql/bin/psql insurance -c vacuum;" su - postgres -c "/usr/local/pgsql/bin/psql intranet -c vacuum;" su - postgres -c "/usr/local/pgsql/bin/psql mailtraq -c vacuum;" su - postgres -c "/usr/local/pgsql/bin/psql pbx -c vacuum;" su - postgres -c "/usr/local/pgsql/bin/psql sitedev -c vacuum;" echo Dumping Database... >> /var/log/backup.log rm /disk1/archive.old mv /disk1/archive.sql /disk1/archive.old su - postgres -c "/usr/local/pgsql/bin/pg_dumpall > /disk1/archive.sql" chown root.root /disk1/archive.sql chmod 600 /disk1/archive.sql echo Done. >> /var/log/backup.log echo Starting TAR dump to DAT... >> /var/log/backup.log echo >> /var/log/backup.log tar cf /dev/st0 -W -P /bin /boot /disk1 /etc /home /lib /mnt /root /sbin /usr /var >> /var/log/backup.log echo >> /var/log/backup.log echo Backup completed: `date` >> /var/log/backup.log /usr/sbin/sendmail root@vale-housing.co.uk < /var/log/backup.log
"Aage J. Skjolingstad" wrote: >Have been searching around the last two days to find some scripts or >cron jobs to automate backup and vacuum. > >I'm running a small db on PSQL 7.02 / RH 7 and keeping my login as >root. > >I know how to set up cron from root and I believe it should be >possible to call the job from root, or am I totally wrong. > >For what I have been doing I only get FATAL 1 errors, believe that's >from not being in su postgres ? > >Any help and assistance (step by step) to a novice would be helpful. Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47 GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Train up a child in the way he should go; and when he is old, he will not depart from it." Proverbs 22:6