Re: backup database by cloning itself

From: Filip Rembiałkowski <filip(dot)rembialkowski(at)gmail(dot)com>
To: filippo <filippo2991(at)virgilio(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: backup database by cloning itself
Date: 2007-02-14 09:41:53
Message-ID: 92869e660702140141l852c7aakb622c2de36f9da08@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

13 Feb 2007 05:54:44 -0800, filippo <filippo2991(at)virgilio(dot)it>:
> Hello,
>
> my database is not very big so I want to adopt this backup strategy:
>
> I want to clone my database every 1 hour to another
> database 'currenttime_mydatabase' in order to have 24 backup a day,
> overwriting the yesterday backups by today-same-time backups.
>
> This is good for me because I have all the backups readily available
> to be read by my program (opening the backup read only). This is a
> very important for my needs.
>
> I'm writing a script run by cron each hour to do accomplish the backup
> task.
>
> My target is to have the backup operation not affecting the users, so
> I want to be able to copy a database even if the database is used by
> someone.
>
> Can I use
> CREATE DATABASE my_backup_database TEMPLATE current_database?

no. database used as template must not be accessed during copy

>
> Is there a better way to get what I need?

you can script this:

pg_dump sourcedb | psql targetdb

--
Filip Rembiałkowski

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2007-02-14 10:01:45 Re: converting a specified year and week into a date
Previous Message A. Kretschmer 2007-02-14 09:33:51 Re: converting a specified year and week into a date