Re: db backup script in gentoo - Mailing list pgsql-general

From Uwe C. Schroeder
Subject Re: db backup script in gentoo
Date
Msg-id 200811291139.26759.uwe@oss4u.com
Whole thread Raw
In response to db backup script in gentoo  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: db backup script in gentoo
Re: db backup script in gentoo
List 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



pgsql-general by date:

Previous
From: Alan Hodgson
Date:
Subject: Re: db backup script in gentoo
Next
From: "Scott Marlowe"
Date:
Subject: Re: db backup script in gentoo