Skip to content

Commit 0912cba

Browse files
committed
Merge branch 'master' into stable
2 parents d0ceaca + c981bf7 commit 0912cba

36 files changed

+4489
-1037
lines changed

src/archive.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@
1818
* --wal-file-path %p --wal-file-name %f', to move backups into arclog_path.
1919
* Where archlog_path is $BACKUP_PATH/wal/system_id.
2020
* Currently it just copies wal files to the new location.
21-
* TODO: Planned options: compress, list the arclog content,
21+
* TODO: Planned options: list the arclog content,
2222
* compute and validate checksums.
2323
*/
2424
int
25-
do_archive_push(char *wal_file_path, char *wal_file_name)
25+
do_archive_push(char *wal_file_path, char *wal_file_name, bool overwrite)
2626
{
2727
char backup_wal_file_path[MAXPGPATH];
2828
char absolute_wal_file_path[MAXPGPATH];
2929
char current_dir[MAXPGPATH];
3030
int64 system_id;
3131
pgBackupConfig *config;
32+
bool is_compress = false;
3233

3334
if (wal_file_name == NULL && wal_file_path == NULL)
34-
elog(ERROR, "required parameters are not specified: --wal_file_name %%f --wal_file_path %%p");
35+
elog(ERROR, "required parameters are not specified: --wal-file-name %%f --wal-file-path %%p");
3536

3637
if (wal_file_name == NULL)
37-
elog(ERROR, "required parameter not specified: --wal_file_name %%f");
38+
elog(ERROR, "required parameter not specified: --wal-file-name %%f");
3839

3940
if (wal_file_path == NULL)
40-
elog(ERROR, "required parameter not specified: --wal_file_path %%p");
41+
elog(ERROR, "required parameter not specified: --wal-file-path %%p");
4142

4243
if (!getcwd(current_dir, sizeof(current_dir)))
4344
elog(ERROR, "getcwd() error");
@@ -61,10 +62,16 @@ do_archive_push(char *wal_file_path, char *wal_file_name)
6162
join_path_components(backup_wal_file_path, arclog_path, wal_file_name);
6263

6364
elog(INFO, "pg_probackup archive-push from %s to %s", absolute_wal_file_path, backup_wal_file_path);
64-
if (access(backup_wal_file_path, F_OK) != -1)
65-
elog(ERROR, "file '%s', already exists.", backup_wal_file_path);
6665

67-
copy_wal_file(absolute_wal_file_path, backup_wal_file_path);
66+
#ifdef HAVE_LIBZ
67+
if (compress_alg == PGLZ_COMPRESS)
68+
elog(ERROR, "pglz compression is not supported");
69+
if (compress_alg == ZLIB_COMPRESS)
70+
is_compress = IsXLogFileName(wal_file_name);
71+
#endif
72+
73+
push_wal_file(absolute_wal_file_path, backup_wal_file_path, is_compress,
74+
overwrite);
6875
elog(INFO, "pg_probackup archive-push completed successfully");
6976

7077
return 0;
@@ -82,22 +89,23 @@ do_archive_get(char *wal_file_path, char *wal_file_name)
8289
char current_dir[MAXPGPATH];
8390

8491
if (wal_file_name == NULL && wal_file_path == NULL)
85-
elog(ERROR, "required parameters are not specified: --wal_file_name %%f --wal_file_path %%p");
92+
elog(ERROR, "required parameters are not specified: --wal-file-name %%f --wal-file-path %%p");
8693

8794
if (wal_file_name == NULL)
88-
elog(ERROR, "required parameter not specified: --wal_file_name %%f");
95+
elog(ERROR, "required parameter not specified: --wal-file-name %%f");
8996

9097
if (wal_file_path == NULL)
91-
elog(ERROR, "required parameter not specified: --wal_file_path %%p");
98+
elog(ERROR, "required parameter not specified: --wal-file-path %%p");
9299

93100
if (!getcwd(current_dir, sizeof(current_dir)))
94101
elog(ERROR, "getcwd() error");
95102

96103
join_path_components(absolute_wal_file_path, current_dir, wal_file_path);
97104
join_path_components(backup_wal_file_path, arclog_path, wal_file_name);
98105

99-
elog(INFO, "pg_probackup archive-get from %s to %s", backup_wal_file_path, absolute_wal_file_path);
100-
copy_wal_file(backup_wal_file_path, absolute_wal_file_path);
106+
elog(INFO, "pg_probackup archive-get from %s to %s",
107+
backup_wal_file_path, absolute_wal_file_path);
108+
get_wal_file(backup_wal_file_path, absolute_wal_file_path);
101109
elog(INFO, "pg_probackup archive-get completed successfully");
102110

103111
return 0;

0 commit comments

Comments
 (0)