I had a need to backup my various databases on my home server. My environment consists of postgresql running on a fedora 17 server.
Backing up
create a cronjob with the command:
crontab -e
put this entry in the file:
50 23 * * * /bin/pg_dumpall -U postgres > /storage/databases/postgres.backup
this tells it to dump all of the databases using the postgres user and put them in a file out in /storage/databases/
Restore
Run the following command as the postgres user.
psql -f /storage/databases/postgres.backup
I back the /storage area up on a nightly basis to external media.
I may in the future incorporate some compression and a file rotation into a script, but at this juncture I haven't had a need for that.
No comments:
Post a Comment