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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have you tried to use the script that PostgreSQL has posted on the wiki?:
motioneyeAuthor Commented:
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
For your case you should only need two files. The with the code provided and pg_backup.config with the configuration options filled in. They should be in the same directory (or edit the path in the code)
You need all three files -

pg_backup.config - The main configuration file. This should be the only file which needs user modifications. - 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. - 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

Open in new window

Sorry, @Mazdajai is correct you need all files.

See this step-by-step, also it may clear things up (it's for Ubuntu but the idea is the same)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.