Link to home
Start Free TrialLog in
Avatar of motioneye
motioneyeFlag for Singapore

asked on

PostgreSQL - How do we run full daily scheduled backup

I'm using Postgresql enterprise db, I wonder how do I run a daily full backups for postgresql and make a removal of old files after 2 weeks ? Is there anyone have the script to complete this task ?
I'm running Postgresql with Redhat Linux
SOLUTION
Avatar of dec0mpile
dec0mpile
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of motioneye

ASKER

Hi dec0mpile,
Thanks, didnt know wiki have something similar...
Should I create as single file then run as sh or do I have to create 3 different files for each of them
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mazdajai
You need all three files -

pg_backup.config - The main configuration file. This should be the only file which needs user modifications.
pg_backup.sh - The normal backup script which will go through each database and save a gzipped and/or a custom format copy of the backup into a date-based directory.
pg_backup_rotated.sh - The same as above except it will delete expired backups based on the configuration.

You can modify the parameter in the backup script to fit your needs -

# Number of days to keep daily backups
DAYS_TO_KEEP=7

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial