Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
d1b88f6b
Commit
d1b88f6b
authored
11 years ago
by
Fujii Masao
Browse files
Options
Downloads
Patches
Plain Diff
Add --xlogdir option to pg_basebackup, for specifying the pg_xlog directory.
Haribabu kommi, slightly modified by me.
parent
551c7828
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/src/sgml/ref/pg_basebackup.sgml
+12
-0
12 additions, 0 deletions
doc/src/sgml/ref/pg_basebackup.sgml
src/bin/pg_basebackup/pg_basebackup.c
+61
-3
61 additions, 3 deletions
src/bin/pg_basebackup/pg_basebackup.c
with
73 additions
and
3 deletions
doc/src/sgml/ref/pg_basebackup.sgml
+
12
−
0
View file @
d1b88f6b
...
@@ -202,6 +202,18 @@ PostgreSQL documentation
...
@@ -202,6 +202,18 @@ PostgreSQL documentation
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><option>--xlogdir=<replaceable class="parameter">xlogdir</replaceable></option></term>
<listitem>
<para>
Specifies the location for the transaction log directory.
<replaceable>xlogdir</replaceable> must be an absolute path.
The transaction log directory can only be specified when
the backup is in plain mode.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><option>-x</option></term>
<term><option>-x</option></term>
<term><option>--xlog</option></term>
<term><option>--xlog</option></term>
...
...
This diff is collapsed.
Click to expand it.
src/bin/pg_basebackup/pg_basebackup.c
+
61
−
3
View file @
d1b88f6b
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
/* Global options */
/* Global options */
char
*
basedir
=
NULL
;
char
*
basedir
=
NULL
;
static
char
*
xlog_dir
=
""
;
char
format
=
'p'
;
/* p(lain)/t(ar) */
char
format
=
'p'
;
/* p(lain)/t(ar) */
char
*
label
=
"pg_basebackup base backup"
;
char
*
label
=
"pg_basebackup base backup"
;
bool
showprogress
=
false
;
bool
showprogress
=
false
;
...
@@ -115,6 +116,7 @@ usage(void)
...
@@ -115,6 +116,7 @@ usage(void)
printf
(
_
(
" -x, --xlog include required WAL files in backup (fetch mode)
\n
"
));
printf
(
_
(
" -x, --xlog include required WAL files in backup (fetch mode)
\n
"
));
printf
(
_
(
" -X, --xlog-method=fetch|stream
\n
"
printf
(
_
(
" -X, --xlog-method=fetch|stream
\n
"
" include required WAL files with specified method
\n
"
));
" include required WAL files with specified method
\n
"
));
printf
(
_
(
" --xlogdir=XLOGDIR location for the transaction log directory
\n
"
));
printf
(
_
(
" -z, --gzip compress tar output
\n
"
));
printf
(
_
(
" -z, --gzip compress tar output
\n
"
));
printf
(
_
(
" -Z, --compress=0-9 compress tar output with given compression level
\n
"
));
printf
(
_
(
" -Z, --compress=0-9 compress tar output with given compression level
\n
"
));
printf
(
_
(
"
\n
General options:
\n
"
));
printf
(
_
(
"
\n
General options:
\n
"
));
...
@@ -980,10 +982,14 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
...
@@ -980,10 +982,14 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
{
{
/*
/*
* When streaming WAL, pg_xlog will have been created
* When streaming WAL, pg_xlog will have been created
* by the wal receiver process, so just ignore failure
* by the wal receiver process. Also, when transaction
* on that.
* log directory location was specified, pg_xlog has
* already been created as a symbolic link before
* starting the actual backup. So just ignore failure
* on them.
*/
*/
if
(
!
streamwal
||
strcmp
(
filename
+
strlen
(
filename
)
-
8
,
"/pg_xlog"
)
!=
0
)
if
((
!
streamwal
&&
(
strcmp
(
xlog_dir
,
""
)
==
0
))
||
strcmp
(
filename
+
strlen
(
filename
)
-
8
,
"/pg_xlog"
)
!=
0
)
{
{
fprintf
(
stderr
,
fprintf
(
stderr
,
_
(
"%s: could not create directory
\"
%s
\"
: %s
\n
"
),
_
(
"%s: could not create directory
\"
%s
\"
: %s
\n
"
),
...
@@ -1666,6 +1672,7 @@ main(int argc, char **argv)
...
@@ -1666,6 +1672,7 @@ main(int argc, char **argv)
{
"status-interval"
,
required_argument
,
NULL
,
's'
},
{
"status-interval"
,
required_argument
,
NULL
,
's'
},
{
"verbose"
,
no_argument
,
NULL
,
'v'
},
{
"verbose"
,
no_argument
,
NULL
,
'v'
},
{
"progress"
,
no_argument
,
NULL
,
'P'
},
{
"progress"
,
no_argument
,
NULL
,
'P'
},
{
"xlogdir"
,
required_argument
,
NULL
,
1
},
{
NULL
,
0
,
NULL
,
0
}
{
NULL
,
0
,
NULL
,
0
}
};
};
int
c
;
int
c
;
...
@@ -1750,6 +1757,9 @@ main(int argc, char **argv)
...
@@ -1750,6 +1757,9 @@ main(int argc, char **argv)
exit
(
1
);
exit
(
1
);
}
}
break
;
break
;
case
1
:
xlog_dir
=
pg_strdup
(
optarg
);
break
;
case
'l'
:
case
'l'
:
label
=
pg_strdup
(
optarg
);
label
=
pg_strdup
(
optarg
);
break
;
break
;
...
@@ -1872,6 +1882,30 @@ main(int argc, char **argv)
...
@@ -1872,6 +1882,30 @@ main(int argc, char **argv)
exit
(
1
);
exit
(
1
);
}
}
if
(
strcmp
(
xlog_dir
,
""
)
!=
0
)
{
if
(
format
!=
'p'
)
{
fprintf
(
stderr
,
_
(
"%s: transaction log directory location can only be specified in plain mode
\n
"
),
progname
);
fprintf
(
stderr
,
_
(
"Try
\"
%s --help
\"
for more information.
\n
"
),
progname
);
exit
(
1
);
}
/* clean up xlog directory name, check it's absolute */
canonicalize_path
(
xlog_dir
);
if
(
!
is_absolute_path
(
xlog_dir
))
{
fprintf
(
stderr
,
_
(
"%s: transaction log directory location must be "
"an absolute path
\n
"
),
progname
);
fprintf
(
stderr
,
_
(
"Try
\"
%s --help
\"
for more information.
\n
"
),
progname
);
exit
(
1
);
}
}
#ifndef HAVE_LIBZ
#ifndef HAVE_LIBZ
if
(
compresslevel
!=
0
)
if
(
compresslevel
!=
0
)
{
{
...
@@ -1890,6 +1924,30 @@ main(int argc, char **argv)
...
@@ -1890,6 +1924,30 @@ main(int argc, char **argv)
if
(
format
==
'p'
||
strcmp
(
basedir
,
"-"
)
!=
0
)
if
(
format
==
'p'
||
strcmp
(
basedir
,
"-"
)
!=
0
)
verify_dir_is_empty_or_create
(
basedir
);
verify_dir_is_empty_or_create
(
basedir
);
/* Create transaction log symlink, if required */
if
(
strcmp
(
xlog_dir
,
""
)
!=
0
)
{
char
*
linkloc
;
verify_dir_is_empty_or_create
(
xlog_dir
);
/* form name of the place where the symlink must go */
linkloc
=
psprintf
(
"%s/pg_xlog"
,
basedir
);
#ifdef HAVE_SYMLINK
if
(
symlink
(
xlog_dir
,
linkloc
)
!=
0
)
{
fprintf
(
stderr
,
_
(
"%s: could not create symbolic link
\"
%s
\"
: %s
\n
"
),
progname
,
linkloc
,
strerror
(
errno
));
exit
(
1
);
}
#else
fprintf
(
stderr
,
_
(
"%s: symlinks are not supported on this platform"
));
exit
(
1
);
#endif
free
(
linkloc
);
}
BaseBackup
();
BaseBackup
();
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment