Don't allow pg_start_backup() to be invoked if archive_command has not
authorNeil Conway <neilc@samurai.com>
Wed, 17 Nov 2004 02:22:54 +0000 (02:22 +0000)
committerNeil Conway <neilc@samurai.com>
Wed, 17 Nov 2004 02:22:54 +0000 (02:22 +0000)
been defined. Patch from Gavin Sherry, editorializing by Neil Conway.

src/backend/access/transam/xlog.c

index ca0a4eafc23ec7743958c670d181ebb0ad85a49e..683ded7f7c741a6469adb4a5806947d62435a4d4 100644 (file)
@@ -5266,6 +5266,14 @@ pg_start_backup(PG_FUNCTION_ARGS)
                ereport(ERROR,
                                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                                 (errmsg("must be superuser to run a backup"))));
+
+       if (!XLogArchivingActive())
+               ereport(ERROR,
+                               (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+                                (errmsg("WAL archiving is not configured"),
+                                (errhint("archive_command must be defined before "
+                                                 "online backups can be safely made.")))));
+
        backupidstr = DatumGetCString(DirectFunctionCall1(textout,
                                                                                         PointerGetDatum(backupid)));