Re: db backup script in gentoo

From: "Uwe C(dot) Schroeder" <uwe(at)oss4u(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: "Andrus" <kobruleht2(at)hot(dot)ee>
Subject: Re: db backup script in gentoo
Date: 2008-11-29 19:39:26
Message-ID: 200811291139.26759.uwe@oss4u.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Saturday 29 November 2008, Andrus wrote:
> How to create automated backup script in Gentoo which in every night 3:00
> PM backups one database and sends backup
> with ftp using unique file name?
>
> In windows I can use scheduler and script
>
> set FILENAME=%DATE:~8,4%%DATE:~5,2%%DATE:~2,2%MyDbBackup
> pg_dump -Z6 -b -v -f "%FILENAME%.backup" -F c -h localhost -U postgres mydb
> ftp -send -u username -p password "%FILENAME%.backup"
> ftp.backupserver.com

Write a shell script that you store someplace you know (i.e. your database
users home directory)

say you name it: /home/whoever/mybackup.sh

#!/bin/sh
cd /someplace/to/store/backups
pg_dump -Fc -R -O -i -Upostgres mydb > mydb_backup`date +'%Y%m%d'`.sql
[FTP STUFF GOES HERE - see below]

save the file. Do a "chmod 755 /home/whoever/mybackup.sh"

type "crontab -e" being logged in as the user who should run this script
("whoever" in the example above)
In the edior add a line like
0 3 * * * /home/whoever/mybackup.sh

save.

Now you'd just have to figure out the ftp part, because I use rdist to push
the copies to a backup machine.

HTH
Uwe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2008-11-29 20:33:08 Re: db backup script in gentoo
Previous Message Alan Hodgson 2008-11-29 19:23:03 Re: db backup script in gentoo