/* Replication permission is not sufficient in this case. */
StartTransactionCommand(); if (!has_privs_of_role(GetUserId(), ROLE_PG_WRITE_SERVER_FILES))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to create backup stored on server"),
errdetail("Only roles with privileges of the \"%s\" role may create a backup stored on the server.", "pg_write_server_files")));
CommitTransactionCommand();
/* *It'snotagoodideatostoreyourbackupsinthesamedirectorythat *you'rebackingup.Ifweallowedarelativepathhere,thatcould *easilyhappenaccidentally,sowedon't.Theusercouldstill *accomplishthesamethingbyincludingtheabsolutepathto$PGDATAin *thepathname,butthat'slikelyanintentionalbaddecisionratherthan *anaccident.
*/ if (!is_absolute_path(pathname))
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
errmsg("relative path not allowed for backup stored on server")));
switch (pg_check_dir(pathname))
{ case0:
/* *Doesnotexist,socreateitusingthesamepermissionswe'd *useforanewsubdirectoryofthedatadirectoryitself.
*/ if (MakePGDirectory(pathname) < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not create directory \"%s\": %m", pathname))); break;
case1: /* Exists, empty. */ break;
case2: case3: case4: /* Exists, not empty. */
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FILE),
errmsg("directory \"%s\" exists but is not empty",
pathname))); break;
if (nbytes != len)
{ if (nbytes < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write file \"%s\": %m",
FilePathName(mysink->file)),
errhint("Check free disk space."))); /* short write: complain appropriately */
ereport(ERROR,
(errcode(ERRCODE_DISK_FULL),
errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %u",
FilePathName(mysink->file),
nbytes, (int) len, (unsigned) mysink->filepos),
errhint("Check free disk space.")));
}
if (nbytes != len)
{ if (nbytes < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write file \"%s\": %m",
FilePathName(mysink->file)),
errhint("Check free disk space."))); /* short write: complain appropriately */
ereport(ERROR,
(errcode(ERRCODE_DISK_FULL),
errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %u",
FilePathName(mysink->file),
nbytes, (int) len, (unsigned) mysink->filepos),
errhint("Check free disk space.")));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.