IsDir was somewhat optimized on systems where DT_DIR (dirent.d_type
being not part of the POSIX spec) is present on some systems leading
to more complex logic depending on the file system used, particularly
on XFS this routine was actually broken. Having a call to stat()
should not be that expensive to check if a path is a directory or
not and this is proving to be far more stable coding, so just rely
on that, that's more portable anyway and will avoid future surprises.
Report by Yury Zhuravlev, though I did not use his patch.
All the ERROR_* fields are removed in favor of a more simple layer
made of ERROR, FATAL, PANIC. The two last ones are not actually used
yet, thought there should be some code paths that would need more
polishing on this matter.
The error message emitted before leaving should be fine to let the
user know what is happening.
--debug and --verbose had actually the same meaning as they were aimed
at giving to the user information regarding how the process is running,
hence both options are merged into --verbose and use elog(LOG) to decide
if a given message should be printed out depending on the verbosity of
the call. This makes a couple of routines more readable as they do not
depend on any boolean checks.
The "_()" have been removed from the code, those are aimed at being used
for translation but having them mandatorily in each log message is just
useless noise. If needed, pgut.c should be updated in consequence to
have a more portable facility.
At the same time this commit takes care of putting into correct shape
some code paths more in-line with PostgreSQL policy. There are surely
more of this kind of ugly stuff but at this stage things are more simple
and more manageable.
Performance of compression is quite questionable on many objects like
that and makes the routines aimed at managing file copy, backup and restore
more complicated than they should be.
This commit results in a largely simplified code in data.c, which will
be helpful when integrating differential backup using WAL file lookup.
This mode is not actually necessary if we consider that the core of
pg_rman is the obtention of differential and full backups, the server
being afterwards in charge to recover necessary WAL segments from the
archive.
Regression tests and documentation are updated in accordance to the
changes.
In order to keep only the core of pg_rman for incremental/differential
backup, this looks necessary and makes the code more simple. Including
server log files in a backup could be subject to discussion as well,
as for example a Postgres base backup does not include them, just
because in this case server instance is not aware of the log files.
This commit simplifies the way backup sizes are saved internally by
reusing the same variable for incremental and full backup, which were
using separated and exclusively used variables, resulted in a couple
of bytes wasted all the time. This was also reflected by a useless
column in the output table of subcommand "show".
This commit makes mandatory the presence of a full backup when doing
an incremental or archive backup on an existing timeline. In this case
the process will now simply error out and not take any backup. It looks
safer to use that as a default by the way, so as user will be forced
to take a full backup once a recovery has been done.
Database backup also contained the following condition when doing an
incremental backup:
prev_backup->tli != current.tli
This means that an incremental backup cannot be taken if there is not
already a full backup present in the same timeline. The same condition
should also be used for archive backup but it didn't seem to be the
case...
Those macros were mainly used in code paths where they didn't make that
much sense, complicating heavily the code. Correct at the same time some
code comments.
In Postgres 9.3, XLogRecPtr has been changed to a unique uint64, making
the old structure based on two uint32 obsolete. Note that this makes
pg_rman incompatible with PG <= 9.2.